diff --git a/src/api/v0.rs b/src/api/v0.rs index 27c1b4d..52491ce 100644 --- a/src/api/v0.rs +++ b/src/api/v0.rs @@ -16,6 +16,7 @@ use { bb8::Pool, std::sync::Arc, crate::{ + time, double_split, }, }; @@ -58,8 +59,8 @@ async fn auth_get(req: Request, pool: DBPool) -> Json { _ => "" }; - let res = con.query_parse::<(String, String)>(&query!( - "SELECT login, uuid FROM bitauth.v0 WHERE session = ?", + let res = con.query_parse::<(String, String, u32)>(&query!( + "SELECT login, uuid, expire FROM bitauth.v0 WHERE session = ?", session )).await; let _ = con.query_parse::<()>(&query!( @@ -67,13 +68,15 @@ async fn auth_get(req: Request, pool: DBPool) -> Json { session )).await; - let (login, uuid) = match res.is_ok() { - false => ("".to_owned(), "".to_owned()), + let (login, uuid, exp) = match res.is_ok() { + false => ("".to_owned(), "".to_owned(), 0), _ => res.unwrap() }; - match login.as_str() { - "" => json!({"error": true, "msg": "Not auth yet"}), - _ => json!({"error": false, "login": login, "uuid": uuid}) + if login.as_str() == "" || exp < time() { + json!({"error": true, "msg": "Not auth yet"}) + } + else { + json!({"error": false, "login": login, "uuid": uuid}) } }