From 7b9d1a78244aa52082691c46cc8b810f15337b35 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 25 Oct 2016 13:55:11 -0700 Subject: [PATCH] auth: Simplify REALMS_HAVE_SUBDOMAINS redirect code. This logic was just a duplicate on realm.uri, except that in the case that subdomains are disabled, it preserves the host in the request. --- zerver/views/auth.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/zerver/views/auth.py b/zerver/views/auth.py index a696ded8d5..ce7d9cf775 100644 --- a/zerver/views/auth.py +++ b/zerver/views/auth.py @@ -85,10 +85,7 @@ def login_or_register_remote_user(request, remote_username, user_profile, full_n else: login(request, user_profile) if settings.REALMS_HAVE_SUBDOMAINS and user_profile.realm.subdomain is not None: - return HttpResponseRedirect("%s%s.%s" % (settings.EXTERNAL_URI_SCHEME, - user_profile.realm.subdomain, - settings.EXTERNAL_HOST)) - + return HttpResponseRedirect(user_profile.realm.uri) return HttpResponseRedirect("%s%s" % (settings.EXTERNAL_URI_SCHEME, request.get_host())) @@ -287,12 +284,8 @@ def dev_direct_login(request, **kwargs): if user_profile is None: raise Exception("User cannot login") login(request, user_profile) - if settings.REALMS_HAVE_SUBDOMAINS and settings.DEVELOPMENT: - if user_profile.realm.subdomain is not None: - return HttpResponseRedirect("%s%s.%s" % (settings.EXTERNAL_URI_SCHEME, - user_profile.realm.subdomain, - settings.EXTERNAL_HOST)) - + if settings.REALMS_HAVE_SUBDOMAINS and user_profile.realm.subdomain is not None: + return HttpResponseRedirect(user_profile.realm.uri) return HttpResponseRedirect("%s%s" % (settings.EXTERNAL_URI_SCHEME, request.get_host()))