Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
email_change: Use HTML error for user deactivated error.
PieterCKcc39b6860b1a
diff --git a/templates/zerver/portico_error_pages/user_deactivated.html b/templates/zerver/portico_error_pages/user_deactivated.htmlnew file mode 100644index 00000000000..c7bf1912f97--- /dev/null+++ b/templates/zerver/portico_error_pages/user_deactivated.html@@ -0,0 +1,20 @@+{% extends "zerver/portico_error_pages/portico_error_page.html" %}++{% block title %}+<title>{{ _("Account is deactivated") }} | Zulip</title>+{% endblock %}++{% block error_page_content %}+<img src="{{ static('images/errors/400art.svg') }}" alt=""/>+<div class="errorbox">+ <div class="errorcontent">+ <h1 class="lead">{{ _("Account is deactivated") }}</h1>+ <p>+ {% trans %}+ Your Zulip account on <a href="{{ realm_url }}">{{ realm_url }}</a>+ has been deactivated, and you will no longer be able to log in.+ {% endtrans %}+ </p>+ </div>+</div>+{% endblock %}diff --git a/zerver/tests/test_email_change.py b/zerver/tests/test_email_change.pyindex ba99fb39269..e589ba820bb 100644--- a/zerver/tests/test_email_change.py+++ b/zerver/tests/test_email_change.py@@ -155,6 +155,8 @@ class EmailChangeTestCase(ZulipTestCase):do_deactivate_user(user_profile, acting_user=None)response = self.client_get(activation_url)self.assertEqual(response.status_code, 401)+ error_page_title = "<title>Account is deactivated | Zulip</title>"+ self.assert_in_response(error_page_title, response)do_reactivate_user(user_profile, acting_user=None)self.login_user(user_profile)diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.pyindex 039d1866ab8..481e8a6c4a5 100644--- a/zerver/views/user_settings.py+++ b/zerver/views/user_settings.py@@ -61,7 +61,6 @@ AVATAR_CHANGES_DISABLED_ERROR = gettext_lazy("Avatar changes are disabled in thidef validate_email_change_request(user_profile: UserProfile, new_email: str) -> None:if not user_profile.is_active:- # TODO: Make this into a user-facing error, not JSONraise UserDeactivatedErrorif user_profile.realm.email_changes_disabled and not user_profile.is_realm_admin:@@ -110,8 +109,16 @@ def confirm_email_change(request: HttpRequest, confirmation_key: str) -> HttpResif user_profile.realm.deactivated:return redirect_to_deactivation_notice()-- validate_email_change_request(user_profile, new_email)+ try:+ validate_email_change_request(user_profile, new_email)+ except UserDeactivatedError:+ context = {"realm_url": user_profile.realm.url}+ return render(+ request,+ "zerver/portico_error_pages/user_deactivated.html",+ context=context,+ status=401,+ )do_change_user_delivery_email(user_profile, new_email, acting_user=user_profile)user_profile = UserProfile.objects.get(id=email_change_object.user_profile_id)