From b423e1c5e66592f6603e13bb65c57d46ebbadee2 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 4 Mar 2026 18:01:22 +0000 Subject: [PATCH] Add users util to check if account has a password. Signed-off-by: Jason Volk --- src/service/users/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/service/users/mod.rs b/src/service/users/mod.rs index e1894564..f175530e 100644 --- a/src/service/users/mod.rs +++ b/src/service/users/mod.rs @@ -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 { + 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 { self.db