diff --git a/app/views.py b/app/views.py index 41d3201..5ae6005 100644 --- a/app/views.py +++ b/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']