diff options
author | Erik Johnston <erik@matrix.org> | 2019-10-18 11:53:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-18 11:53:02 +0200 |
commit | d98029ea89ffc19a80a00299c1f2aff06f7b778d (patch) | |
tree | 2156796e5e8bef890dc3c7b6c82c8d61423ada8a /synapse/rest/admin/_base.py | |
parent | Add missing BOOLEAN_COLUMNs to synapse_port_db (#6216) (diff) | |
parent | Port synapse/rest/client/_base.py to async/await (diff) | |
download | synapse-d98029ea89ffc19a80a00299c1f2aff06f7b778d.tar.xz |
Merge pull request #6196 from matrix-org/erikj/await
Move rest/admin to use async/await.
Diffstat (limited to 'synapse/rest/admin/_base.py')
-rw-r--r-- | synapse/rest/admin/_base.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/synapse/rest/admin/_base.py b/synapse/rest/admin/_base.py index 5a9b08d3ef..afd0647205 100644 --- a/synapse/rest/admin/_base.py +++ b/synapse/rest/admin/_base.py @@ -15,8 +15,6 @@ import re -from twisted.internet import defer - from synapse.api.errors import AuthError @@ -42,8 +40,7 @@ def historical_admin_path_patterns(path_regex): ) -@defer.inlineCallbacks -def assert_requester_is_admin(auth, request): +async def assert_requester_is_admin(auth, request): """Verify that the requester is an admin user WARNING: MAKE SURE YOU YIELD ON THE RESULT! @@ -58,12 +55,11 @@ def assert_requester_is_admin(auth, request): Raises: AuthError if the requester is not an admin """ - requester = yield auth.get_user_by_req(request) - yield assert_user_is_admin(auth, requester.user) + requester = await auth.get_user_by_req(request) + await assert_user_is_admin(auth, requester.user) -@defer.inlineCallbacks -def assert_user_is_admin(auth, user_id): +async def assert_user_is_admin(auth, user_id): """Verify that the given user is an admin user WARNING: MAKE SURE YOU YIELD ON THE RESULT! @@ -79,6 +75,6 @@ def assert_user_is_admin(auth, user_id): AuthError if the user is not an admin """ - is_admin = yield auth.is_server_admin(user_id) + is_admin = await auth.is_server_admin(user_id) if not is_admin: raise AuthError(403, "You are not a server admin") |