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

Commit

Permalink
Revert another status code change
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson committed Jul 20, 2022
1 parent dc1f188 commit ad801d9
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions synapse/rest/client/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,6 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
return 200, ret


class PasswordBody(BaseModel):
auth: Optional[AuthenticationData] = None
logout_devices: StrictBool = True
if TYPE_CHECKING:
# workaround for https://github.com/samuelcolvin/pydantic/issues/156
new_password: Optional[str] = None
else:
new_password: Optional[constr(max_length=512)] = None


class PasswordRestServlet(RestServlet):
PATTERNS = client_patterns("/account/password$")

Expand All @@ -169,9 +159,18 @@ def __init__(self, hs: "HomeServer"):
self.password_policy_handler = hs.get_password_policy_handler()
self._set_password_handler = hs.get_set_password_handler()

class PostBody(BaseModel):
auth: Optional[AuthenticationData] = None
logout_devices: StrictBool = True
if TYPE_CHECKING:
# workaround for https://github.com/samuelcolvin/pydantic/issues/156
new_password: Optional[str] = None
else:
new_password: Optional[constr(max_length=512)] = None

@interactive_auth_handler
async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
body = parse_and_validate_json_object_from_request(request, PasswordBody)
body = parse_and_validate_json_object_from_request(request, self.PostBody)

# we do basic sanity checks here because the auth layer will store these
# in sessions. Pull out the new password provided to us.
Expand Down Expand Up @@ -284,13 +283,6 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
return 200, {}


class DeactivateAccountBody(BaseModel):
auth: Optional[AuthenticationData] = None
id_server: Optional[StrictStr] = None
# Not specced, see https://github.com/matrix-org/matrix-spec/issues/297
erase: StrictBool = False


class DeactivateAccountRestServlet(RestServlet):
PATTERNS = client_patterns("/account/deactivate$")

Expand All @@ -301,10 +293,16 @@ def __init__(self, hs: "HomeServer"):
self.auth_handler = hs.get_auth_handler()
self._deactivate_account_handler = hs.get_deactivate_account_handler()

class PostBody(BaseModel):
auth: Optional[AuthenticationData] = None
id_server: Optional[StrictStr] = None
# Not specced, see https://github.com/matrix-org/matrix-spec/issues/297
erase: StrictBool = False

@interactive_auth_handler
async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
body = parse_and_validate_json_object_from_request(
request, DeactivateAccountBody
request, self.PostBody
)

requester = await self.auth.get_user_by_req(request)
Expand Down Expand Up @@ -358,9 +356,8 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
"Adding emails have been disabled due to lack of an email config"
)
raise SynapseError(
HTTPStatus.NOT_FOUND,
400,
"Adding an email to your account is disabled on this server",
Codes.NOT_FOUND,
)

body = parse_and_validate_json_object_from_request(
Expand Down

0 comments on commit ad801d9

Please sign in to comment.