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

Commit 8dd2ea6

Browse files
authored
Consistently check whether a password may be set for a user. (#9636)
1 parent dd71eb0 commit 8dd2ea6

File tree

5 files changed

+122
-57
lines changed

5 files changed

+122
-57
lines changed

changelog.d/9636.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Checks if passwords are allowed before setting it for the user.

synapse/handlers/set_password.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async def set_password(
4141
logout_devices: bool,
4242
requester: Optional[Requester] = None,
4343
) -> None:
44-
if not self.hs.config.password_localdb_enabled:
44+
if not self._auth_handler.can_change_password():
4545
raise SynapseError(403, "Password change disabled", errcode=Codes.FORBIDDEN)
4646

4747
try:

synapse/rest/admin/users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ async def on_PUT(
271271
elif not deactivate and user["deactivated"]:
272272
if (
273273
"password" not in body
274-
and self.hs.config.password_localdb_enabled
274+
and self.auth_handler.can_change_password()
275275
):
276276
raise SynapseError(
277277
400, "Must provide a password to re-activate an account."

synapse/storage/databases/main/registration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,7 @@ def set_user_deactivated_status_txn(self, txn, user_id: str, deactivated: bool):
12101210
self._invalidate_cache_and_stream(
12111211
txn, self.get_user_deactivated_status, (user_id,)
12121212
)
1213+
self._invalidate_cache_and_stream(txn, self.get_user_by_id, (user_id,))
12131214
txn.call_after(self.is_guest.invalidate, (user_id,))
12141215

12151216
@cached()

0 commit comments

Comments
 (0)