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

Commit fcd8703

Browse files
authored
Allow updating passwords using the admin api without logging out devices (#12952)
1 parent e3163e2 commit fcd8703

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

changelog.d/12952.feature

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow updating a user's password using the admin API without logging out their devices. Contributed by @jcgruenhage.

docs/admin_api/user_admin_api.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ URL parameters:
115115
Body parameters:
116116

117117
- `password` - string, optional. If provided, the user's password is updated and all
118-
devices are logged out.
118+
devices are logged out, unless `logout_devices` is set to `false`.
119+
- `logout_devices` - bool, optional, defaults to `true`. If set to false, devices aren't
120+
logged out even when `password` is provided.
119121
- `displayname` - string, optional, defaults to the value of `user_id`.
120122
- `threepids` - array, optional, allows setting the third-party IDs (email, msisdn)
121123
- `medium` - string. Kind of third-party ID, either `email` or `msisdn`.

synapse/rest/admin/users.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ async def on_PUT(
226226
if not isinstance(password, str) or len(password) > 512:
227227
raise SynapseError(HTTPStatus.BAD_REQUEST, "Invalid password")
228228

229+
logout_devices = body.get("logout_devices", True)
230+
if not isinstance(logout_devices, bool):
231+
raise SynapseError(
232+
HTTPStatus.BAD_REQUEST,
233+
"'logout_devices' parameter is not of type boolean",
234+
)
235+
229236
deactivate = body.get("deactivated", False)
230237
if not isinstance(deactivate, bool):
231238
raise SynapseError(
@@ -305,7 +312,6 @@ async def on_PUT(
305312
await self.store.set_server_admin(target_user, set_admin_to)
306313

307314
if password is not None:
308-
logout_devices = True
309315
new_password_hash = await self.auth_handler.hash(password)
310316

311317
await self.set_password_handler.set_password(

0 commit comments

Comments
 (0)