fix: checking auth

This commit is contained in:
Artemy 2022-08-11 16:38:12 +03:00
parent b99e8dadd0
commit 37c3c3f069
3 changed files with 10 additions and 3 deletions

1
.gitignore vendored
View file

@ -22,3 +22,4 @@ dist-ssr
*.njsproj
*.sln
*.sw?
options.json

View file

@ -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,
}
}

View file

@ -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 {