diff --git a/server/src/auth.rs b/server/src/auth.rs index 69b4ffb..4a5fd4d 100644 --- a/server/src/auth.rs +++ b/server/src/auth.rs @@ -6,7 +6,7 @@ use crate::db_types::{BigInt, Integer, UBigInt, VarChar}; use crate::routes; // used when we create a new users for the first time -pub const _BCRYPT_COST: u32 = 14; +pub const BCRYPT_COST: u32 = 14; pub enum AuthReason { Good, //passed regular check OpenAuth, // route does not require auth @@ -22,10 +22,10 @@ fn open_route(path: &str) -> bool { fn valid_user(secret: &str, row: &Option<(VarChar, VarChar, BigInt, Integer, UBigInt)>) -> bool { match row { Some(row) => { - if let Ok(result) = bcrypt::verify(secret, &row.0) { - return result; + match bcrypt::verify(secret, &row.0) { + Ok(result) => result, + Err(_) => return false } - return false; }, _ => return false } @@ -39,7 +39,7 @@ pub async fn wall_entry(path: &str, pool: &Pool, params: &mut serde_json::Value) else { match (params.get("id"), params.get("secret")) { (Some(id_v), Some(secret_v)) => { - let id = id_v.as_str().unwrap(); + let id = id_v.as_u64().unwrap(); let secret = secret_v.as_str().unwrap(); let conn = pool.get_conn().await?; let db_tup: (Conn, Option<(VarChar, VarChar, BigInt, Integer, UBigInt)>) = conn.first_exec(