Merge pull request #20 from wulkanowy/bugfix/keyerror_at_userid
Fix Keyerror: userid error
This commit is contained in:
commit
5fdb7fdedc
1 changed files with 3 additions and 12 deletions
15
app/views.py
15
app/views.py
|
@ -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']
|
||||
|
|
Loading…
Reference in a new issue