From 37c3c3f069ed87bdd6fd29d9fd72592bd7348034 Mon Sep 17 00:00:00 2001 From: Artemy Date: Thu, 11 Aug 2022 16:38:12 +0300 Subject: [PATCH] fix: checking auth --- .gitignore | 1 + src-tauri/src/commands.rs | 10 ++++++++-- src-tauri/src/main.rs | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index a547bf3..0bf99b2 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ dist-ssr *.njsproj *.sln *.sw? +options.json diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 2b607dd..5e9aae8 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -11,11 +11,17 @@ pub fn check_auth(state: State) -> 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, } } diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index f982343..2e3ae48 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -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::(&options).unwrap_or(AppData {