mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
api: Add REALM_DEACTIVATED error code.
In `validate_account_and_subdomain` we check if user's realm 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 users with deactivated realms for non-browser clients. So we register a new REALM_DEACTIVATED error code so that clients can distinguish if error is because of deactivated account. Following these changes `validate_account_and_subdomain` raises RealmDeactivatedError if user's realm is deactivated. This error is also documented in `/api/rest-error-handling`. Testing: I have mostly relied on automated backend tests to test this. Fixes #17763.
This commit is contained in:
committed by
Tim Abbott
parent
2eeb82edba
commit
aea31eb31f
@@ -51,6 +51,7 @@ class ErrorCode(AbstractEnum):
|
||||
NONEXISTENT_SUBDOMAIN = ()
|
||||
RATE_LIMIT_HIT = ()
|
||||
USER_DEACTIVATED = ()
|
||||
REALM_DEACTIVATED = ()
|
||||
|
||||
|
||||
class JsonableError(Exception):
|
||||
@@ -284,6 +285,18 @@ class UserDeactivatedError(JsonableError):
|
||||
return _("Account is deactivated")
|
||||
|
||||
|
||||
class RealmDeactivatedError(JsonableError):
|
||||
code: ErrorCode = ErrorCode.REALM_DEACTIVATED
|
||||
http_status_code = 403
|
||||
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def msg_format() -> str:
|
||||
return _("This organization has been deactivated")
|
||||
|
||||
|
||||
class MarkdownRenderingException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user