auth: Change the look of SOCIAL_AUTH_SUBDOMAIN when directly opened.

SOCIAL_AUTH_SUBDOMAIN was potentially very confusing when opened by a
user, as it had various Login/Signup buttons as if there was a realm on
it. Instead, we want to display a more informative page to the user
telling them they shouldn't even be there. If possible, we just redirect
them to the realm they most likely came from.
To make this possible, we have to exclude the subdomain from
ROOT_SUBDOMAIN_ALIASES - so that we can give it special behavior.
This commit is contained in:
Mateusz Mandera
2021-08-23 15:14:05 +02:00
committed by Tim Abbott
parent cf2302b272
commit fb3864ea3c
7 changed files with 71 additions and 7 deletions

View File

@@ -576,7 +576,10 @@ class HostDomainMiddleware(MiddlewareMixin):
return None
subdomain = get_subdomain(request)
if subdomain != Realm.SUBDOMAIN_FOR_ROOT_DOMAIN:
if (
subdomain != Realm.SUBDOMAIN_FOR_ROOT_DOMAIN
and subdomain != settings.SOCIAL_AUTH_SUBDOMAIN
):
request_notes = RequestNotes.get_notes(request)
try:
request_notes.realm = get_realm(subdomain)