Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
auth: Check if realm is active before checking if user is active.
Mateusz Mandera159e8a014152
diff --git a/zproject/backends.py b/zproject/backends.pyindex e103fab02b8..d8eff0f697b 100644--- a/zproject/backends.py+++ b/zproject/backends.py@@ -170,6 +170,10 @@ def require_email_format_usernames(realm: Optional[Realm] = None) -> bool:def is_user_active(user_profile: UserProfile, return_data: Optional[Dict[str, Any]] = None) -> bool:+ if user_profile.realm.deactivated:+ if return_data is not None:+ return_data["inactive_realm"] = True+ return Falseif not user_profile.is_active:if return_data is not None:if user_profile.is_mirror_dummy:@@ -178,10 +182,6 @@ def is_user_active(user_profile: UserProfile, return_data: Optional[Dict[str, Anreturn_data["inactive_user"] = Truereturn_data["inactive_user_id"] = user_profile.idreturn False- if user_profile.realm.deactivated:- if return_data is not None:- return_data["inactive_realm"] = True- return Falsereturn True@@ -1560,6 +1560,10 @@ def social_auth_finish(return HttpResponseRedirect(reverse("find_account"))realm = Realm.objects.get(id=return_data["realm_id"])+ if auth_backend_disabled or inactive_realm or no_verified_email or email_not_associated:+ # Redirect to login page. We can't send to registration+ # workflow with these errors. We will redirect to login page.+ return redirect_to_login(realm)if inactive_user:backend.logger.info("Failed login attempt for deactivated account: %s@%s",@@ -1568,11 +1572,6 @@ def social_auth_finish()return redirect_deactivated_user_to_login(realm, return_data["validated_email"])- if auth_backend_disabled or inactive_realm or no_verified_email or email_not_associated:- # Redirect to login page. We can't send to registration- # workflow with these errors. We will redirect to login page.- return redirect_to_login(realm)-if invalid_email:# In case of invalid email, we will end up on registration page.# This seems better than redirecting to login page.