mirror of
https://github.com/OSMA-D/osma-app.git
synced 2024-12-05 02:56:23 +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
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
|
options.json
|
||||||
|
|
|
@ -11,11 +11,17 @@ pub fn check_auth(state: State<AppData>) -> bool {
|
||||||
} else {
|
} else {
|
||||||
let client = Client::new();
|
let client = Client::new();
|
||||||
let response = client
|
let response = client
|
||||||
.get("https://osma-server.herokuapp.com/personal_library")
|
.get("https://osma-server.herokuapp.com/api/personal_library")
|
||||||
.bearer_auth(&state.jwt)
|
.bearer_auth(&state.jwt)
|
||||||
.send();
|
.send();
|
||||||
match response {
|
match response {
|
||||||
Ok(_) => true,
|
Ok(response) => {
|
||||||
|
if response.status().is_success() {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
Err(_) => false,
|
Err(_) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ use types::*;
|
||||||
|
|
||||||
mod commands;
|
mod commands;
|
||||||
fn main() {
|
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()
|
tauri::Builder::default()
|
||||||
.manage(
|
.manage(
|
||||||
serde_json::from_str::<AppData>(&options).unwrap_or(AppData {
|
serde_json::from_str::<AppData>(&options).unwrap_or(AppData {
|
||||||
|
|
Loading…
Add table
Reference in a new issue