Skip to content

Commit c88cb9c

Browse files
committed
Better feedback when changing passwords
1 parent 341ac89 commit c88cb9c

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

crates/handlers/src/graphql/mutations/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ async fn verify_password_if_needed(
8484
password,
8585
user_password.hashed_password,
8686
)
87-
.await;
87+
.await?;
8888

89-
Ok(res.is_ok())
89+
Ok(res.is_success())
9090
}

crates/handlers/src/graphql/mutations/user.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,13 +737,14 @@ impl UserMutations {
737737
));
738738
};
739739

740-
if let Err(_err) = password_manager
740+
if !password_manager
741741
.verify(
742742
active_password.version,
743743
Zeroizing::new(current_password_attempt),
744744
active_password.hashed_password,
745745
)
746-
.await
746+
.await?
747+
.is_success()
747748
{
748749
return Ok(SetPasswordPayload {
749750
status: SetPasswordStatus::WrongPassword,

crates/handlers/src/passwords.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ impl<T> PasswordVerificationResult<T> {
4949
Self::Failure => PasswordVerificationResult::Failure,
5050
}
5151
}
52+
53+
#[must_use]
54+
pub fn is_success(&self) -> bool {
55+
matches!(self, Self::Success(_))
56+
}
5257
}
5358

5459
impl From<bool> for PasswordVerificationResult<()> {

0 commit comments

Comments
 (0)