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