backend: Add support for mobile_flow_otp in social auth.

It turns out that very little code change is required to support
GitHub auth on mobile.  Ideally, this would come with tests, though
the complicated part of the code path is covered by the Google auth
version.  But writing a test for this would take a long time, and I
think it's worth having the feature now, so I'll be doing tests as a
follow-up project.
This commit is contained in:
Tim Abbott 2017-09-29 15:30:55 -07:00
parent 327db90a3d
commit 63bbbba5aa
2 changed files with 4 additions and 2 deletions

View File

@ -229,10 +229,12 @@ class SocialAuthMixin(ZulipAuthMixin):
is_signup = strategy.session_get('is_signup') == '1' is_signup = strategy.session_get('is_signup') == '1'
subdomain = strategy.session_get('subdomain') subdomain = strategy.session_get('subdomain')
if not subdomain: mobile_flow_otp = strategy.session_get('mobile_flow_otp')
if not subdomain or mobile_flow_otp is not None:
return login_or_register_remote_user(request, email_address, return login_or_register_remote_user(request, email_address,
user_profile, full_name, user_profile, full_name,
invalid_subdomain=bool(invalid_subdomain), invalid_subdomain=bool(invalid_subdomain),
mobile_flow_otp=mobile_flow_otp,
is_signup=is_signup) is_signup=is_signup)
try: try:
realm = Realm.objects.get(string_id=subdomain) realm = Realm.objects.get(string_id=subdomain)

View File

@ -1366,7 +1366,7 @@ else:
# SOCIAL AUTHENTICATION SETTINGS # SOCIAL AUTHENTICATION SETTINGS
######################################################################## ########################################################################
SOCIAL_AUTH_FIELDS_STORED_IN_SESSION = ['subdomain', 'is_signup'] SOCIAL_AUTH_FIELDS_STORED_IN_SESSION = ['subdomain', 'is_signup', 'mobile_flow_otp']
SOCIAL_AUTH_LOGIN_ERROR_URL = '/login/' SOCIAL_AUTH_LOGIN_ERROR_URL = '/login/'
SOCIAL_AUTH_GITHUB_SECRET = get_secret('social_auth_github_secret') SOCIAL_AUTH_GITHUB_SECRET = get_secret('social_auth_github_secret')