fix: Generate token function
This commit is contained in:
parent
821a0c405c
commit
dd50a175e6
@ -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
|
||||||
|
|
||||||
|
@ -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()
|
||||||
|
Loading…
Reference in New Issue
Block a user