Skip to content

Commit

Permalink
Return specific error code when email / phone not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
dbkr committed Aug 16, 2024
1 parent 9ce489b commit bcc5a7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions synapse/api/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Codes(str, Enum):
THREEPID_NOT_FOUND = "M_THREEPID_NOT_FOUND"
THREEPID_DENIED = "M_THREEPID_DENIED"
INVALID_USERNAME = "M_INVALID_USERNAME"
THREEPID_MEDIUM_NOT_SUPPORTED = "M_THREEPID_MEDIUM_NOT_SUPPORTED"
SERVER_NOT_TRUSTED = "M_SERVER_NOT_TRUSTED"
CONSENT_NOT_GIVEN = "M_CONSENT_NOT_GIVEN"
CANNOT_LEAVE_SERVER_NOTICE_ROOM = "M_CANNOT_LEAVE_SERVER_NOTICE_ROOM"
Expand Down
5 changes: 4 additions & 1 deletion synapse/rest/client/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
raise SynapseError(
400,
"Adding an email to your account is disabled on this server",
Codes.THREEPID_MEDIUM_NOT_SUPPORTED
)

body = parse_and_validate_json_object_from_request(
Expand Down Expand Up @@ -463,6 +464,7 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
raise SynapseError(
400,
"Adding phone numbers to user account is not supported by this homeserver",
Codes.THREEPID_MEDIUM_NOT_SUPPORTED
)

ret = await self.identity_handler.requestMsisdnToken(
Expand Down Expand Up @@ -505,7 +507,8 @@ async def on_GET(self, request: Request) -> None:
"Adding emails have been disabled due to lack of an email config"
)
raise SynapseError(
400, "Adding an email to your account is disabled on this server"
400, "Adding an email to your account is disabled on this server",
Codes.THREEPID_MEDIUM_NOT_SUPPORTED
)

sid = parse_string(request, "sid", required=True)
Expand Down

0 comments on commit bcc5a7c

Please sign in to comment.