Ensure login tokens always get attached to the user.

This commit is contained in:
Adarnof 2018-02-22 13:40:02 -05:00
parent ef24bea562
commit 5060d3f408

View File

@ -71,17 +71,19 @@ have the email address embedded much like the username. Key creation and decodin
@token_required(new=True, scopes=settings.LOGIN_TOKEN_SCOPES) @token_required(new=True, scopes=settings.LOGIN_TOKEN_SCOPES)
def sso_login(request, token): def sso_login(request, token):
user = authenticate(token=token) user = authenticate(token=token)
if user and user.is_active: if user:
login(request, user) token.user = user
return redirect(request.POST.get('next', request.GET.get('next', 'authentication:dashboard'))) token.save()
elif user and not user.email: if user.is_active:
# Store the new user PK in the session to enable us to identify the registering user in Step 2 login(request, user)
request.session['registration_uid'] = user.pk return redirect(request.POST.get('next', request.GET.get('next', 'authentication:dashboard')))
# Go to Step 2 elif not user.email:
return redirect('registration_register') # Store the new user PK in the session to enable us to identify the registering user in Step 2
else: request.session['registration_uid'] = user.pk
messages.error(request, _('Unable to authenticate as the selected character.')) # Go to Step 2
return redirect(settings.LOGIN_URL) return redirect('registration_register')
messages.error(request, _('Unable to authenticate as the selected character.'))
return redirect(settings.LOGIN_URL)
# Step 2 # Step 2