fix: Generate token function
All checks were successful
Build Docker / Build Main Image (push) Successful in 18s
Build Docker / Build SLDs Image (push) Successful in 18s

This commit is contained in:
Nathan Woodburn 2023-11-08 19:06:08 +11:00
parent 821a0c405c
commit dd50a175e6
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
2 changed files with 3 additions and 8 deletions

View File

@ -26,12 +26,8 @@ def verify_password(password, hashed_password):
def generate_cookie(): def generate_cookie():
token = os.urandom(24).hex() token = os.urandom(24).hex()
# Verify token doesn't already exist # Verify token doesn't already exist
with open('users.json', 'r') as f: while db.search_users_token(token) != []:
users = json.load(f) token = os.urandom(24).hex()
for user in users:
if token in user['tokens']:
print('Token already exists, generating new one')
return generate_cookie()
return token return token

View File

@ -5,8 +5,7 @@ import requests
import json import json
import schedule import schedule
import time import time
from email_validator import validate_email, EmailNotValidError
import accounts
app = Flask(__name__) app = Flask(__name__)
dotenv.load_dotenv() dotenv.load_dotenv()