Show realm deactivation notice for login/register.

Fixes #6247
This commit is contained in:
Umair Khan 2017-08-24 12:58:44 +05:00 committed by Tim Abbott
parent 07a156c400
commit b473ff54ce
3 changed files with 24 additions and 1 deletions

View File

@ -32,7 +32,7 @@ from zerver.lib.validator import validate_login_email
from zerver.models import PreregistrationUser, UserProfile, remote_user_to_email, Realm, \
get_realm
from zerver.views.registration import create_preregistration_user, get_realm_from_request, \
redirect_and_log_into_subdomain
redirect_and_log_into_subdomain, redirect_to_deactivation_notice
from zerver.signals import email_on_new_login
from zproject.backends import password_auth_enabled, dev_auth_enabled, \
github_auth_enabled, google_auth_enabled, ldap_auth_enabled
@ -465,6 +465,10 @@ def login_page(request, **kwargs):
redirect_url = reverse('zerver.views.registration.find_my_team')
return HttpResponseRedirect(redirect_url)
realm = get_realm_from_request(request)
if realm and realm.deactivated:
return redirect_to_deactivation_notice()
extra_context = kwargs.pop('extra_context', {})
if dev_auth_enabled():
if 'new_realm' in request.POST:

View File

@ -340,9 +340,25 @@ def get_realm_from_request(request):
realm_str = None
return get_realm(realm_str)
def show_deactivation_notice(request):
# type: (HttpRequest) -> HttpResponse
realm = get_realm_from_request(request)
if realm and realm.deactivated:
return render(request, "zerver/deactivated.html",
context={"deactivated_domain_name": realm.name})
return HttpResponseRedirect(reverse('zerver.views.auth.login_page'))
def redirect_to_deactivation_notice():
# type: () -> HttpResponse
return HttpResponseRedirect(reverse('zerver.views.registration.show_deactivation_notice'))
def accounts_home(request):
# type: (HttpRequest) -> HttpResponse
realm = get_realm_from_request(request)
if realm and realm.deactivated:
return redirect_to_deactivation_notice()
if request.method == 'POST':
form = HomepageForm(request.POST, realm=realm)
if form.is_valid():

View File

@ -95,6 +95,9 @@ i18n_urls = [
name='django.contrib.auth.views.password_reset_confirm'),
url(r'^accounts/password/done/$', password_reset_complete,
{'template_name': 'zerver/reset_done.html'}),
url(r'^accounts/deactivated/',
zerver.views.registration.show_deactivation_notice,
name='zerver.views.registration.show_deactivation_notice'),
# Avatar
url(r'^avatar/(?P<email_or_id>[\S]+)?/(?P<medium>[\S]+)?', zerver.views.users.avatar, name='zerver.views.users.avatar'),