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;
|
use crate::routes;
|
||||||
|
|
||||||
// used when we create a new users for the first time
|
// 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 {
|
pub enum AuthReason {
|
||||||
Good, //passed regular check
|
Good, //passed regular check
|
||||||
OpenAuth, // route does not require auth
|
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 {
|
fn valid_user(secret: &str, row: &Option<(VarChar, VarChar, BigInt, Integer, UBigInt)>) -> bool {
|
||||||
match row {
|
match row {
|
||||||
Some(row) => {
|
Some(row) => {
|
||||||
if let Ok(result) = bcrypt::verify(secret, &row.0) {
|
match bcrypt::verify(secret, &row.0) {
|
||||||
return result;
|
Ok(result) => result,
|
||||||
|
Err(_) => return false
|
||||||
}
|
}
|
||||||
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 {
|
else {
|
||||||
match (params.get("id"), params.get("secret")) {
|
match (params.get("id"), params.get("secret")) {
|
||||||
(Some(id_v), Some(secret_v)) => {
|
(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 secret = secret_v.as_str().unwrap();
|
||||||
let conn = pool.get_conn().await?;
|
let conn = pool.get_conn().await?;
|
||||||
let db_tup: (Conn, Option<(VarChar, VarChar, BigInt, Integer, UBigInt)>) = conn.first_exec(
|
let db_tup: (Conn, Option<(VarChar, VarChar, BigInt, Integer, UBigInt)>) = conn.first_exec(
|
||||||
|
Loading…
Reference in New Issue
Block a user