From dd50a175e6d2499f36209f7f9112d85f9e202b69 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 8 Nov 2023 19:06:08 +1100 Subject: [PATCH] fix: Generate token function --- accounts.py | 8 ++------ sites/slds.py | 3 +-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/accounts.py b/accounts.py index 65b3f51..bcfdaa6 100644 --- a/accounts.py +++ b/accounts.py @@ -26,12 +26,8 @@ def verify_password(password, hashed_password): def generate_cookie(): token = os.urandom(24).hex() # Verify token doesn't already exist - with open('users.json', 'r') as f: - users = json.load(f) - for user in users: - if token in user['tokens']: - print('Token already exists, generating new one') - return generate_cookie() + while db.search_users_token(token) != []: + token = os.urandom(24).hex() return token diff --git a/sites/slds.py b/sites/slds.py index a1e1d74..39bfeb8 100644 --- a/sites/slds.py +++ b/sites/slds.py @@ -5,8 +5,7 @@ import requests import json import schedule import time -from email_validator import validate_email, EmailNotValidError -import accounts + app = Flask(__name__) dotenv.load_dotenv()