decorator: Check for deactivated realm before deactivated user.

Structurally, this is the right order-of-access for data.
This commit is contained in:
Tim Abbott 2018-08-09 15:57:18 -07:00
parent aaedec1fdb
commit a124db5f7b

View File

@ -231,11 +231,10 @@ def validate_api_key(request: HttpRequest, role: Optional[str],
return user_profile
def validate_account_and_subdomain(request: HttpRequest, user_profile: UserProfile) -> None:
if not user_profile.is_active:
raise JsonableError(_("Account not active"))
if user_profile.realm.deactivated:
raise JsonableError(_("This organization has been deactivated"))
if not user_profile.is_active:
raise JsonableError(_("Account not active"))
# Either the subdomain matches, or processing a websockets message
# in the message_sender worker (which will have already had the