Skip to content

Commit

Permalink
Ensure 'deactivated' parameter is a boolean on user admin API, Fix er…
Browse files Browse the repository at this point in the history
…ror handling of call to deactivate user (matrix-org#6990)
  • Loading branch information
anoadragon453 authored and phil-flex committed Mar 27, 2020
1 parent 61ac743 commit f1e01dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.d/6990.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevent user from setting 'deactivated' to anything other than a bool on the v2 PUT /users Admin API.
11 changes: 7 additions & 4 deletions synapse/rest/admin/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,16 @@ async def on_PUT(self, request, user_id):
)

if "deactivated" in body:
deactivate = bool(body["deactivated"])
deactivate = body["deactivated"]
if not isinstance(deactivate, bool):
raise SynapseError(
400, "'deactivated' parameter is not of type boolean"
)

if deactivate and not user["deactivated"]:
result = await self.deactivate_account_handler.deactivate_account(
await self.deactivate_account_handler.deactivate_account(
target_user.to_string(), False
)
if not result:
raise SynapseError(500, "Could not deactivate user")

user = await self.admin_handler.get_user(target_user)
return 200, user
Expand Down

0 comments on commit f1e01dd

Please sign in to comment.