mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2025-03-13 22:52:40 +00:00
Merge 2a6c7a566a
into 970987c5f7
This commit is contained in:
commit
51aa0d4780
1 changed files with 15 additions and 2 deletions
|
@ -58,11 +58,24 @@ pub async fn validate_credentials(
|
|||
expected_password_hash = stored_password_hash;
|
||||
}
|
||||
|
||||
spawn_blocking_with_tracing(move || {
|
||||
match spawn_blocking_with_tracing(move || {
|
||||
verify_password_hash(expected_password_hash, credentials.password)
|
||||
})
|
||||
.await
|
||||
.context("Failed to spawn blocking task.")??;
|
||||
.context("Failed to spawn blocking task.")?
|
||||
{
|
||||
Ok(_) => Ok(()),
|
||||
Err(e) => match e {
|
||||
AuthError::InvalidCredentials(_) => {
|
||||
if user_id.is_none() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
_ => Err(e),
|
||||
},
|
||||
}?;
|
||||
|
||||
user_id
|
||||
.ok_or_else(|| anyhow::anyhow!("Unknown username."))
|
||||
|
|
Loading…
Reference in a new issue