diff --git a/synapse/api/auth_blocking.py b/synapse/api/auth_blocking.py index a3f8654128..9c227218e0 100644 --- a/synapse/api/auth_blocking.py +++ b/synapse/api/auth_blocking.py @@ -61,8 +61,14 @@ class AuthBlocking: certain blocking reasons like MAU. requester: If present, and the authenticated entity is a user, checks for - presence against existing MAU cohort. + presence against existing MAU cohort. Passing in both a `user_id` and + `requester` is an error. """ + if requester and user_id: + raise Exception( + "Passed in both 'user_id' and 'requester' to 'check_auth_blocking'" + ) + if requester: if requester.authenticated_entity.startswith("@"): user_id = requester.authenticated_entity diff --git a/synapse/rest/admin/users.py b/synapse/rest/admin/users.py index 933617cccd..bcb38532e2 100644 --- a/synapse/rest/admin/users.py +++ b/synapse/rest/admin/users.py @@ -851,7 +851,7 @@ class UserTokenRestServlet(RestServlet): if not self.hs.is_mine_id(user_id): raise SynapseError(400, "Only local users can be logged in as") - body = parse_json_object_from_request(request) + body = parse_json_object_from_request(request, allow_empty_body=True) valid_until_ms = body.get("valid_until_ms") if valid_until_ms and not isinstance(valid_until_ms, int): diff --git a/tests/rest/admin/test_user.py b/tests/rest/admin/test_user.py index f168367694..c1d7af7c5f 100644 --- a/tests/rest/admin/test_user.py +++ b/tests/rest/admin/test_user.py @@ -1759,6 +1759,6 @@ class UserTokenRestTestCase(unittest.HomeserverTestCase): ) # Logging in as the other user and joining a room should work, even - # though they should be denied. + # though the MAU limit would stop the user doing so. puppet_token = self._get_token() self.helper.join(room_id, user=self.other_user, tok=puppet_token)