mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
api: Add USER_DEACTIVATED error code.
In validate_account_and_subdomain we check if user's account is not deactivated. In case of failure of this check we raise our standard JsonableError. While this works well in most cases but it creates difficulties in handling of deactivated accounts for non-browser clients. So we register a new USER_DEACTIVATED error code so that clients can distinguish if error is because of deactivated account. Following these changes `validate_account_and_subdomain` raises UserDeactivatedError if user's account is deactivated. This error is also documented in `/api/rest-error-handling`. Testing: I have mostly relied on automated backend tests to test this. Partially addresses issue #17763.
This commit is contained in:
committed by
Tim Abbott
parent
66d7e711b2
commit
2eeb82edba
@@ -50,6 +50,7 @@ class ErrorCode(AbstractEnum):
|
||||
UNAUTHENTICATED_USER = ()
|
||||
NONEXISTENT_SUBDOMAIN = ()
|
||||
RATE_LIMIT_HIT = ()
|
||||
USER_DEACTIVATED = ()
|
||||
|
||||
|
||||
class JsonableError(Exception):
|
||||
@@ -271,6 +272,18 @@ class StreamAdministratorRequired(JsonableError):
|
||||
return _("Must be an organization or stream administrator")
|
||||
|
||||
|
||||
class UserDeactivatedError(JsonableError):
|
||||
code: ErrorCode = ErrorCode.USER_DEACTIVATED
|
||||
http_status_code = 403
|
||||
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def msg_format() -> str:
|
||||
return _("Account is deactivated")
|
||||
|
||||
|
||||
class MarkdownRenderingException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user