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

improve human readable error messages #3789

Merged
merged 3 commits into from
Sep 4, 2018
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/3789.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve human readable error messages for threepid registration/account update
16 changes: 12 additions & 4 deletions synapse/rest/client/v2_alpha/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def on_POST(self, request):

if not check_3pid_allowed(self.hs, "email", body['email']):
raise SynapseError(
403, "Third party identifier is not allowed", Codes.THREEPID_DENIED,
403,
"Your email domain is not authorized on this server",
Codes.THREEPID_DENIED,
)

existingUid = yield self.hs.get_datastore().get_user_id_by_threepid(
Expand Down Expand Up @@ -89,7 +91,9 @@ def on_POST(self, request):

if not check_3pid_allowed(self.hs, "msisdn", msisdn):
raise SynapseError(
403, "Third party identifier is not allowed", Codes.THREEPID_DENIED,
403,
"Account phone numbers are not authorized on this server",
Codes.THREEPID_DENIED,
)

existingUid = yield self.datastore.get_user_id_by_threepid(
Expand Down Expand Up @@ -241,7 +245,9 @@ def on_POST(self, request):

if not check_3pid_allowed(self.hs, "email", body['email']):
raise SynapseError(
403, "Third party identifier is not allowed", Codes.THREEPID_DENIED,
403,
"Your email domain is not authorized on this server",
Codes.THREEPID_DENIED,
)

existingUid = yield self.datastore.get_user_id_by_threepid(
Expand Down Expand Up @@ -276,7 +282,9 @@ def on_POST(self, request):

if not check_3pid_allowed(self.hs, "msisdn", msisdn):
raise SynapseError(
403, "Third party identifier is not allowed", Codes.THREEPID_DENIED,
403,
"Account phone numbers are not authorized on this server",
Codes.THREEPID_DENIED,
)

existingUid = yield self.datastore.get_user_id_by_threepid(
Expand Down
12 changes: 9 additions & 3 deletions synapse/rest/client/v2_alpha/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def on_POST(self, request):

if not check_3pid_allowed(self.hs, "email", body['email']):
raise SynapseError(
403, "Third party identifier is not allowed", Codes.THREEPID_DENIED,
403,
"Your email domain is not authorized to register on this server",
Codes.THREEPID_DENIED,
)

existingUid = yield self.hs.get_datastore().get_user_id_by_threepid(
Expand Down Expand Up @@ -115,7 +117,9 @@ def on_POST(self, request):

if not check_3pid_allowed(self.hs, "msisdn", msisdn):
raise SynapseError(
403, "Third party identifier is not allowed", Codes.THREEPID_DENIED,
403,
"Phone numbers are not authorized to register on this server",
Codes.THREEPID_DENIED,
)

existingUid = yield self.hs.get_datastore().get_user_id_by_threepid(
Expand Down Expand Up @@ -373,7 +377,9 @@ def on_POST(self, request):

if not check_3pid_allowed(self.hs, medium, address):
raise SynapseError(
403, "Third party identifier is not allowed",
403,
"Third party identifiers (email/phone numbers)" +
" are not authorized on this server",
Codes.THREEPID_DENIED,
)

Expand Down