Merge pull request #42 from IcyNet/display-name-to-session

Added user display name to session on login
This commit is contained in:
Tsa6 2017-09-25 18:10:26 -04:00 committed by GitHub
commit 3b01197b21

View File

@ -50,6 +50,7 @@ class LoginRedirect(View):
).json()
req.session['user_id'] = user_info['uuid']
matches = User.objects.filter(user_id=user_info['uuid'])
match = None
if not len(matches):
user = User(
user_id = user_info['uuid'],
@ -57,7 +58,11 @@ class LoginRedirect(View):
display_name = user_info['display_name']
)
user.save()
match = user
else:
match = matches[0]
req.session['token'] = resp_json['access_token']
req.session['disp_name'] = match.display_name
return HttpResponseRedirect('/')
else:
return HttpResponse('<h1>Unmatching state tokens</h1><br><p>It looks like the request to login wasn\'t started by you. Try going back to the home page and logging in again.</p>', status=400)