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

Fix errorcode for disabled registration #8867

Merged
merged 1 commit into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
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