Fix KeyError: userid
This commit is contained in:
parent
e3ba086d6f
commit
ff31fd32d2
2 changed files with 8 additions and 2 deletions
|
@ -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')
|
||||
|
@ -46,12 +47,16 @@ def login(request, *args, **kwargs):
|
|||
break
|
||||
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)
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue