Fix changing password via user admin API. (#6730)
parent
e9e066055f
commit
ceecedc68b
|
@ -0,0 +1 @@
|
|||
Fix changing password via user admin API.
|
|
@ -193,8 +193,8 @@ class UserRestServletV2(RestServlet):
|
|||
raise SynapseError(400, "Invalid password")
|
||||
else:
|
||||
new_password = body["password"]
|
||||
await self._set_password_handler.set_password(
|
||||
target_user, new_password, requester
|
||||
await self.set_password_handler.set_password(
|
||||
target_user.to_string(), new_password, requester
|
||||
)
|
||||
|
||||
if "deactivated" in body:
|
||||
|
|
|
@ -435,6 +435,19 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
self.assertEqual(0, channel.json_body["is_guest"])
|
||||
self.assertEqual(0, channel.json_body["deactivated"])
|
||||
|
||||
# Change password
|
||||
body = json.dumps({"password": "hahaha"})
|
||||
|
||||
request, channel = self.make_request(
|
||||
"PUT",
|
||||
self.url,
|
||||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
# Modify user
|
||||
body = json.dumps({"displayname": "foobar", "deactivated": True})
|
||||
|
||||
|
|
Loading…
Reference in New Issue