Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Convert status codes to HTTPStatus in synapse.rest.admin #11452

Merged
merged 4 commits into from
Nov 29, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Apply suggestions from code review
Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
dklimpel and squahtx authored Nov 29, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit ca9f2adfee78d2e4e1fd910f68741fc10df38525
4 changes: 2 additions & 2 deletions synapse/rest/admin/users.py
Original file line number Diff line number Diff line change
@@ -531,7 +531,7 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
want_mac = want_mac_builder.hexdigest()

if not hmac.compare_digest(want_mac.encode("ascii"), got_mac.encode("ascii")):
raise SynapseError(HTTPStatus.UNAUTHORIZED, "HMAC incorrect")
raise SynapseError(HTTPStatus.FORBIDDEN, "HMAC incorrect")

# Reuse the parts of RegisterRestServlet to reduce code duplication
from synapse.rest.client.register import RegisterRestServlet
@@ -738,7 +738,7 @@ async def on_GET(

# To allow all users to get the users list
# if not is_admin and target_user != auth_user:
# raise AuthError(HTTPStatus.UNAUTHORIZED, "You are not a server admin")
# raise AuthError(HTTPStatus.FORBIDDEN, "You are not a server admin")

if not self.hs.is_mine(target_user):
raise SynapseError(HTTPStatus.BAD_REQUEST, "Can only users a local user")