Fix KeyError: userid

This commit is contained in:
Tomasz 2021-01-28 11:06:57 +01:00
parent e3ba086d6f
commit ff31fd32d2
2 changed files with 8 additions and 2 deletions

View file

@ -39,6 +39,7 @@ def login(request, *args, **kwargs):
'success': False
}
else:
request.session['is_logged'] = True
while True:
try:
request.session[request.session.session_key] = Fernet.generate_key().decode('utf-8')
@ -47,11 +48,15 @@ def login(request, *args, **kwargs):
except KeyError:
continue
while True:
if request.session.has_key(request.session.session_key):
break
print(request.session.session_key)
sender_return['s'] = json.dumps(sender_return['s'])
sender_return['s'] = sender_return['s'].encode()
sender_return['s'] = rkey.encrypt(sender_return['s'])
sender_return['s'] = sender_return['s'].decode('utf-8')
request.session['is_logged'] = True
data_response = {'success': True, 'data': sender_return}
return JsonResponse(data_response)

View file

@ -2,6 +2,7 @@ from django.shortcuts import render
from django.shortcuts import redirect
def default_view(request, *args, **kwargs):
request.session['has_session'] = True
return render(request, 'frontend/index.html')
def content_view(request, *args, **kwargs):