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

Commit

Permalink
Fix errorcode for disabled registration (#8867)
Browse files Browse the repository at this point in the history
The spec says we should return `M_FORBIDDEN` when someone tries to register and
registration is disabled.
  • Loading branch information
richvdh authored Dec 3, 2020
1 parent 66f75c5 commit cf3b815
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/8867.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix the error code that is returned when a user tries to register on a homeserver on which new-user registration has been disabled.
2 changes: 1 addition & 1 deletion synapse/rest/client/v2_alpha/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ async def on_POST(self, request):

# == Normal User Registration == (everyone else)
if not self._registration_enabled:
raise SynapseError(403, "Registration has been disabled")
raise SynapseError(403, "Registration has been disabled", Codes.FORBIDDEN)

# For regular registration, convert the provided username to lowercase
# before attempting to register it. This should mean that people who try
Expand Down
1 change: 1 addition & 0 deletions tests/rest/client/v2_alpha/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def test_POST_disabled_registration(self):

self.assertEquals(channel.result["code"], b"403", channel.result)
self.assertEquals(channel.json_body["error"], "Registration has been disabled")
self.assertEquals(channel.json_body["errcode"], "M_FORBIDDEN")

def test_POST_guest_registration(self):
self.hs.config.macaroon_secret_key = "test"
Expand Down

0 comments on commit cf3b815

Please sign in to comment.