diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2020-06-05 14:33:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-05 14:33:49 +0100 |
commit | eea124370bbf8667cbd6a6af418d9df67654ce34 (patch) | |
tree | ecaf072f7f089ec149580b775fb6abc6270f5e4a /synapse/rest | |
parent | Remove some unused constants. (#7644) (diff) | |
download | synapse-eea124370bbf8667cbd6a6af418d9df67654ce34.tar.xz |
Fix type information on `assert_*_is_admin` methods (#7645)
These things don't return Deferreds.
Diffstat (limited to 'synapse/rest')
-rw-r--r-- | synapse/rest/admin/_base.py | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/synapse/rest/admin/_base.py b/synapse/rest/admin/_base.py index a96f75ce26..d82eaf5e38 100644 --- a/synapse/rest/admin/_base.py +++ b/synapse/rest/admin/_base.py @@ -15,7 +15,11 @@ import re +import twisted.web.server + +import synapse.api.auth from synapse.api.errors import AuthError +from synapse.types import UserID def historical_admin_path_patterns(path_regex): @@ -55,41 +59,32 @@ def admin_patterns(path_regex: str): return patterns -async def assert_requester_is_admin(auth, request): +async def assert_requester_is_admin( + auth: synapse.api.auth.Auth, request: twisted.web.server.Request +) -> None: """Verify that the requester is an admin user - WARNING: MAKE SURE YOU YIELD ON THE RESULT! - Args: - auth (synapse.api.auth.Auth): - request (twisted.web.server.Request): incoming request - - Returns: - Deferred + auth: api.auth.Auth singleton + request: incoming request Raises: - AuthError if the requester is not an admin + AuthError if the requester is not a server admin """ requester = await auth.get_user_by_req(request) await assert_user_is_admin(auth, requester.user) -async def assert_user_is_admin(auth, user_id): +async def assert_user_is_admin(auth: synapse.api.auth.Auth, user_id: UserID) -> None: """Verify that the given user is an admin user - WARNING: MAKE SURE YOU YIELD ON THE RESULT! - Args: - auth (synapse.api.auth.Auth): - user_id (UserID): - - Returns: - Deferred + auth: api.auth.Auth singleton + user_id: user to check Raises: - AuthError if the user is not an admin + AuthError if the user is not a server admin """ - is_admin = await auth.is_server_admin(user_id) if not is_admin: raise AuthError(403, "You are not a server admin") |