Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Consistently check whether a password may be set for a user. (#9636)
Browse files Browse the repository at this point in the history
  • Loading branch information
dklimpel authored Mar 18, 2021
1 parent dd71eb0 commit 8dd2ea6
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 57 deletions.
1 change: 1 addition & 0 deletions changelog.d/9636.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Checks if passwords are allowed before setting it for the user.
2 changes: 1 addition & 1 deletion synapse/handlers/set_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def set_password(
logout_devices: bool,
requester: Optional[Requester] = None,
) -> None:
if not self.hs.config.password_localdb_enabled:
if not self._auth_handler.can_change_password():
raise SynapseError(403, "Password change disabled", errcode=Codes.FORBIDDEN)

try:
Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/admin/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ async def on_PUT(
elif not deactivate and user["deactivated"]:
if (
"password" not in body
and self.hs.config.password_localdb_enabled
and self.auth_handler.can_change_password()
):
raise SynapseError(
400, "Must provide a password to re-activate an account."
Expand Down
1 change: 1 addition & 0 deletions synapse/storage/databases/main/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,7 @@ def set_user_deactivated_status_txn(self, txn, user_id: str, deactivated: bool):
self._invalidate_cache_and_stream(
txn, self.get_user_deactivated_status, (user_id,)
)
self._invalidate_cache_and_stream(txn, self.get_user_by_id, (user_id,))
txn.call_after(self.is_guest.invalidate, (user_id,))

@cached()
Expand Down
Loading

0 comments on commit 8dd2ea6

Please sign in to comment.