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.
This commit is contained in:
Tim Abbott
2016-10-25 13:55:11 -07:00
parent b5816bf99e
commit 7b9d1a7824

View File

@@ -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()))