Skip to content

Commit

Permalink
mod: use original argon settings
Browse files Browse the repository at this point in the history
  • Loading branch information
bennjii committed Dec 28, 2023
1 parent 544ea3c commit 45fc363
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@ default = ["all"]

[profile.release]
strip = false

[profile.dev]
split-debuginfo = "unpacked"
8 changes: 6 additions & 2 deletions src/methods/employee/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl Employee {

let password = empl.password.clone();
let salt = b"randomsalt";
let config = Config::default();
let config = Config::original();
let hash = argon2::hash_encoded(password.as_bytes(), salt, &config).unwrap();

let insert_crud = empl.into_active(id, rid, session.tenant_id, hash);
Expand Down Expand Up @@ -242,9 +242,13 @@ impl Employee {
let mut valid_user: Option<Employee> = None;

for employee in employee {
println!("Validating employee");

let is_valid = argon2::verify_encoded(
&employee.auth.hash, pass.as_bytes()
).unwrap();
).map_err(|e| DbErr::RecordNotFound(e.to_string()))?;

println!("Found employee is {}", if is_valid { "Valid" } else { "Invalid" });

if is_valid && valid_user.is_none() {
valid_user = Some(employee);
Expand Down

0 comments on commit 45fc363

Please sign in to comment.