Fix InvalidToken error

This commit is contained in:
Tomasz 2021-01-29 23:30:36 +01:00
parent b45cde1dbf
commit 03f7808b3d
2 changed files with 4 additions and 7 deletions

View file

@ -40,13 +40,8 @@ def login(request, *args, **kwargs):
} }
else: else:
request.session['is_logged'] = True request.session['is_logged'] = True
while True: request.session[request.session.session_key] = Fernet.generate_key().decode('utf-8')
try: rkey = Fernet(bytes(request.session[request.session.session_key], 'utf-8'))
request.session[request.session.session_key] = Fernet.generate_key().decode('utf-8')
rkey = Fernet(bytes(request.session[request.session.session_key], 'utf-8'))
break
except KeyError:
continue
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()

View file

@ -5,6 +5,7 @@ const login = () => {
const Password = document.querySelector('#id_Password').value; const Password = document.querySelector('#id_Password').value;
const symbol = document.querySelector('#id_Symbol').value; const symbol = document.querySelector('#id_Symbol').value;
const diary = document.querySelector('#id_diary').value; const diary = document.querySelector('#id_diary').value;
button.removeEventListener('click', login)
if(loginName != '' && Password != '' && symbol != ''){ if(loginName != '' && Password != '' && symbol != ''){
switch(diary){ switch(diary){
case 'Fakelog': case 'Fakelog':
@ -43,6 +44,7 @@ const login = () => {
else{ else{
document.querySelector('#error').innerHTML = 'Nieprawidłowy login, hasło lub symbol'; document.querySelector('#error').innerHTML = 'Nieprawidłowy login, hasło lub symbol';
} }
button.addEventListener('click', login);
}); });
} }
}; };