Added user display name to session on login

This commit is contained in:
Taizo 'Tsa6' Simpson 2017-09-25 18:08:43 -04:00
parent 2242ce2878
commit 3b195eb763

View File

@ -50,6 +50,7 @@ class LoginRedirect(View):
).json() ).json()
req.session['user_id'] = user_info['uuid'] req.session['user_id'] = user_info['uuid']
matches = User.objects.filter(user_id=user_info['uuid']) matches = User.objects.filter(user_id=user_info['uuid'])
match = None
if not len(matches): if not len(matches):
user = User( user = User(
user_id = user_info['uuid'], user_id = user_info['uuid'],
@ -57,7 +58,11 @@ class LoginRedirect(View):
display_name = user_info['display_name'] display_name = user_info['display_name']
) )
user.save() user.save()
match = user
else:
match = matches[0]
req.session['token'] = resp_json['access_token'] req.session['token'] = resp_json['access_token']
req.session['disp_name'] = match.display_name
return HttpResponseRedirect('/') return HttpResponseRedirect('/')
else: 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) 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)