Defined conn earlier

This commit is contained in:
Tracker-Friendly 2024-03-28 17:55:01 +00:00
parent e27cf47083
commit 313d81742f
1 changed files with 1 additions and 1 deletions

2
main
View File

@ -272,6 +272,7 @@ async def apicreateauth():
appId = data["appId"] appId = data["appId"]
secretKey = data["secretKey"] secretKey = data["secretKey"]
secret = str(secrets.token_hex(512)) secret = str(secrets.token_hex(512))
conn = get_db_connection()
while True: while True:
if not secret == str(conn.execute("SELECT secret FROM oauth WHERE secret = ?", (str(secret)))).fetchone(): if not secret == str(conn.execute("SELECT secret FROM oauth WHERE secret = ?", (str(secret)))).fetchone():
break break
@ -285,7 +286,6 @@ async def apicreateauth():
userCookie = get_session(secretKey) userCookie = get_session(secretKey)
user = get_user(userCookie["id"]) user = get_user(userCookie["id"])
conn = get_db_connection()
conn.execute("INSERT INTO keys (appId, creator, secret) VALUES (?, ?, ?)", conn.execute("INSERT INTO keys (appId, creator, secret) VALUES (?, ?, ?)",
(str(appId),int(user["id"]),str(secret))) (str(appId),int(user["id"]),str(secret)))
conn.commit() conn.commit()