Add users util to check if account has a password.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2026-03-04 18:01:22 +00:00
parent 0420f527c5
commit b423e1c5e6

View File

@@ -206,6 +206,14 @@ impl Service {
.deserialized()
}
/// Returns whether the user has a password. Disabled accounts and
/// registrations setting a sentinel password will return false here.
pub async fn has_password(&self, user_id: &UserId) -> Result<bool> {
self.password_hash(user_id)
.map_ok(|value| value != PASSWORD_DISABLED && value != PASSWORD_SENTINEL)
.await
}
/// Returns the password hash for the given user.
pub async fn password_hash(&self, user_id: &UserId) -> Result<String> {
self.db