mirror of
https://github.com/OSMA-D/osma-app.git
synced 2024-11-05 21:24:04 +03:00
fix: checking auth
This commit is contained in:
parent
b99e8dadd0
commit
37c3c3f069
3 changed files with 10 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -22,3 +22,4 @@ dist-ssr
|
|||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
options.json
|
||||
|
|
|
@ -11,11 +11,17 @@ pub fn check_auth(state: State<AppData>) -> bool {
|
|||
} else {
|
||||
let client = Client::new();
|
||||
let response = client
|
||||
.get("https://osma-server.herokuapp.com/personal_library")
|
||||
.get("https://osma-server.herokuapp.com/api/personal_library")
|
||||
.bearer_auth(&state.jwt)
|
||||
.send();
|
||||
match response {
|
||||
Ok(_) => true,
|
||||
Ok(response) => {
|
||||
if response.status().is_success() {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
Err(_) => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use types::*;
|
|||
|
||||
mod commands;
|
||||
fn main() {
|
||||
let options = fs::read_to_string("./options.json").unwrap_or("{\"jwt\":null}".to_string());
|
||||
let options = fs::read_to_string("options.json").unwrap_or("{\"jwt\":null}".to_string());
|
||||
tauri::Builder::default()
|
||||
.manage(
|
||||
serde_json::from_str::<AppData>(&options).unwrap_or(AppData {
|
||||
|
|
Loading…
Reference in a new issue