Show new users an error page when they try to sign up for a deactivated realm.

(imported from commit 1696a6a5d26ec92b881cd3fda43e6b262e2fbfa5)
This commit is contained in:
Jessica McKellar
2014-01-07 13:04:26 -05:00
parent 511e1a12e3
commit 32549ec135
3 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
{% extends "zerver/portico.html" %}
{% block portico_content %}
<h3>Deactivated organization</h3>
<p>Hi there! Thank you for your interest in Zulip.</p>
<p>The organization you are trying to join, {{ deactivated_domain_name }}, has
been deactivated. Please
contact <a href="mailto:support@zulip.com">support@zulip.com</a> to reactivate
this group.</p>
{% endblock %}

View File

@@ -811,6 +811,21 @@ class LoginTest(AuthedTestCase):
user_profile = get_user_profile_by_email('test@zulip.com')
self.assertEqual(self.client.session['_auth_user_id'], user_profile.id)
def test_register_deactivated(self):
"""
If you try to register for a deactivated realm, you get a clear error
page.
"""
realm = Realm.objects.get(domain="zulip.com")
realm.deactivated = True
realm.save(update_fields=["deactivated"])
result = self.register("test", "test")
self.assertIn("has been deactivated", result.content.replace("\n", " "))
with self.assertRaises(UserProfile.DoesNotExist):
get_user_profile_by_email('test@zulip.com')
def test_logout(self):
self.login("hamlet@zulip.com")
self.client.post('/accounts/logout/')

View File

@@ -241,6 +241,13 @@ def accounts_register(request):
else:
domain = resolve_email_to_domain(email)
realm = get_realm(domain)
if realm and realm.deactivated:
# The user is trying to register for a deactivated realm. Advise them to
# contact support.
return render_to_response("zerver/deactivated.html",
{"deactivated_domain_name": realm.name})
try:
if mit_beta_user:
# MIT users already exist, but are supposed to be inactive.