mirror of https://github.com/zulip/zulip.git
subdomains: Clean up a use of various falsy values for the root domain.
This isn't a complete cleanup of the logic at this spot, but at least the messy part that remains is now explicit.
This commit is contained in:
parent
4a6e867046
commit
27adbe8d79
|
@ -498,7 +498,7 @@ class GitHubAuthBackendTest(ZulipTestCase):
|
|||
request.session = {}
|
||||
request.user = self.user_profile
|
||||
self.backend.strategy.request = request
|
||||
session_data = {'subdomain': False, 'is_signup': '1'}
|
||||
session_data = {'subdomain': Realm.SUBDOMAIN_FOR_ROOT_DOMAIN, 'is_signup': '1'}
|
||||
self.backend.strategy.session_get = lambda k: session_data.get(k)
|
||||
|
||||
def do_auth(*args, **kwargs):
|
||||
|
@ -524,7 +524,7 @@ class GitHubAuthBackendTest(ZulipTestCase):
|
|||
request.session = {}
|
||||
request.user = self.user_profile
|
||||
self.backend.strategy.request = request
|
||||
session_data = {'subdomain': False, 'is_signup': '1'}
|
||||
session_data = {'subdomain': Realm.SUBDOMAIN_FOR_ROOT_DOMAIN, 'is_signup': '1'}
|
||||
self.backend.strategy.session_get = lambda k: session_data.get(k)
|
||||
|
||||
def do_auth(*args, **kwargs):
|
||||
|
@ -570,7 +570,7 @@ class GitHubAuthBackendTest(ZulipTestCase):
|
|||
request.session = {}
|
||||
request.user = self.user_profile
|
||||
self.backend.strategy.request = request
|
||||
session_data = {'subdomain': False, 'is_signup': '1'}
|
||||
session_data = {'subdomain': Realm.SUBDOMAIN_FOR_ROOT_DOMAIN, 'is_signup': '1'}
|
||||
self.backend.strategy.session_get = lambda k: session_data.get(k)
|
||||
|
||||
def do_auth(*args, **kwargs):
|
||||
|
@ -595,7 +595,7 @@ class GitHubAuthBackendTest(ZulipTestCase):
|
|||
request.session = {}
|
||||
request.user = self.user_profile
|
||||
self.backend.strategy.request = request
|
||||
session_data = {'subdomain': False, 'is_signup': '0'}
|
||||
session_data = {'subdomain': Realm.SUBDOMAIN_FOR_ROOT_DOMAIN, 'is_signup': '0'}
|
||||
self.backend.strategy.session_get = lambda k: session_data.get(k)
|
||||
|
||||
def do_auth(*args, **kwargs):
|
||||
|
|
|
@ -221,9 +221,17 @@ class SocialAuthMixin(ZulipAuthMixin):
|
|||
full_name = self.get_full_name(*args, **kwargs)
|
||||
is_signup = strategy.session_get('is_signup') == '1'
|
||||
|
||||
subdomain = strategy.session_get('subdomain')
|
||||
mobile_flow_otp = strategy.session_get('mobile_flow_otp')
|
||||
if not subdomain or mobile_flow_otp is not None:
|
||||
subdomain = strategy.session_get('subdomain')
|
||||
if not subdomain:
|
||||
# At least in our tests, this can be None; and it's not
|
||||
# clear what the exact semantics of `session_get` are or
|
||||
# what values it might return. Historically we treated
|
||||
# any falsy value here as the root domain, so defensively
|
||||
# continue that behavior.
|
||||
subdomain = Realm.SUBDOMAIN_FOR_ROOT_DOMAIN
|
||||
if (subdomain == Realm.SUBDOMAIN_FOR_ROOT_DOMAIN
|
||||
or mobile_flow_otp is not None):
|
||||
return login_or_register_remote_user(request, email_address,
|
||||
user_profile, full_name,
|
||||
invalid_subdomain=bool(invalid_subdomain),
|
||||
|
|
Loading…
Reference in New Issue