Merge pull request #20 from wulkanowy/bugfix/keyerror_at_userid

Fix Keyerror: userid error
This commit is contained in:
Pengwius 2021-01-25 10:59:58 +01:00 committed by GitHub
commit 5fdb7fdedc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -39,23 +39,13 @@ def login(request, *args, **kwargs):
'success': False
}
else:
key = Fernet.generate_key()
request.session[request.session.session_key] = Fernet.generate_key().decode('utf-8')
key = bytes(request.session[request.session.session_key], 'utf-8')
rkey = Fernet(key)
x = None
request.session[request.session.session_key] = key.decode('utf-8')
while x == None:
try:
x = request.session[request.session.session_key]
x = x
except KeyError:
x = None
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)
@ -267,6 +257,7 @@ def dashboard(request, *args, **kwargs):
register_r = data['data']['register_r']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
print(key)
s = decrypt_cookies(s, key)
diary_url = data['data']['diary_url']
symbol = data['data']['symbol']