Merge pull request #18 from wulkanowy/bugfix/keyerror_at_userid

Fix KeyError: userid error
This commit is contained in:
Marcin Kowalicki 2021-01-23 22:20:08 +01:00 committed by GitHub
commit ca39721f87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -41,8 +41,16 @@ def login(request, *args, **kwargs):
else: else:
key = Fernet.generate_key() key = Fernet.generate_key()
rkey = Fernet(key) rkey = Fernet(key)
x = None
request.session[request.session.session_key] = key.decode('utf-8') 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'] = json.dumps(sender_return['s'])
sender_return['s'] = sender_return['s'].encode() sender_return['s'] = sender_return['s'].encode()
sender_return['s'] = rkey.encrypt(sender_return['s']) sender_return['s'] = rkey.encrypt(sender_return['s'])