Return m.change_password.enabled=false if local database is disabled (#9588)

Instead of if the user does not have a password hash. This allows a SSO
user to add a password to their account, but only if the local password
database is configured.
This commit is contained in:
Dirk Klimpel 2021-03-16 16:44:25 +01:00 committed by GitHub
parent e3bc0e6f7c
commit 8000cf1315
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 15 deletions

View file

@ -886,6 +886,19 @@ class AuthHandler(BaseHandler):
)
return result
def can_change_password(self) -> bool:
"""Get whether users on this server are allowed to change or set a password.
Both `config.password_enabled` and `config.password_localdb_enabled` must be true.
Note that any account (even SSO accounts) are allowed to add passwords if the above
is true.
Returns:
Whether users on this server are allowed to change or set a password
"""
return self._password_enabled and self._password_localdb_enabled
def get_supported_login_types(self) -> Iterable[str]:
"""Get a the login types supported for the /login API