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

Commit 72167fb

Browse files
Change user deactivated errcode to USER_DEACTIVATED and use it (#5686)
This is intended as an amendment to #5674 as using M_UNKNOWN as the errcode makes it hard for clients to differentiate between an invalid password and a deactivated user (the problem we were trying to solve in the first place). M_UNKNOWN was originally chosen as it was presumed than an MSC would have to be carried out to add a new code, but as Synapse often is the testing bed for new MSC implementations, it makes sense to try it out first in the wild and then add it into the spec if it is successful. Thus this PR return a new M_USER_DEACTIVATED code when a deactivated user attempts to login.
1 parent 58a755c commit 72167fb

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

changelog.d/5686.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use `M_USER_DEACTIVATED` instead of `M_UNKNOWN` for errcode when a deactivated user attempts to login.

synapse/api/errors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class Codes(object):
6161
INCOMPATIBLE_ROOM_VERSION = "M_INCOMPATIBLE_ROOM_VERSION"
6262
WRONG_ROOM_KEYS_VERSION = "M_WRONG_ROOM_KEYS_VERSION"
6363
EXPIRED_ACCOUNT = "ORG_MATRIX_EXPIRED_ACCOUNT"
64+
USER_DEACTIVATED = "M_USER_DEACTIVATED"
6465

6566

6667
class CodeMessageException(RuntimeError):
@@ -151,7 +152,7 @@ def __init__(self, msg):
151152
msg (str): The human-readable error message
152153
"""
153154
super(UserDeactivatedError, self).__init__(
154-
code=http_client.FORBIDDEN, msg=msg, errcode=Codes.UNKNOWN
155+
code=http_client.FORBIDDEN, msg=msg, errcode=Codes.USER_DEACTIVATED
155156
)
156157

157158

0 commit comments

Comments
 (0)