Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
2e97a4c1
Commit
2e97a4c1
authored
5 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Port synapse/rest/client/_base.py to async/await
parent
3c2d6c70
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/rest/admin/_base.py
+5
-9
5 additions, 9 deletions
synapse/rest/admin/_base.py
with
5 additions
and
9 deletions
synapse/rest/admin/_base.py
+
5
−
9
View file @
2e97a4c1
...
...
@@ -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
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment