verification of secrets now has clearer fallback
This commit is contained in:
parent
90e6496786
commit
b3d603eecc
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user