arg correct + verbose
This commit is contained in:
@@ -61,11 +61,11 @@ async def fetch_user_info(arg: str, type: str):
|
||||
if db.mode == "mysql":
|
||||
async with db.pool.acquire() as conn:
|
||||
async with conn.cursor(aiomysql.DictCursor) as cur:
|
||||
await cur.execute("SELECT * FROM users WHERE %s = %s", (arg,type))
|
||||
await cur.execute("SELECT * FROM users WHERE %s = %s", (type, arg))
|
||||
return await cur.fetchone()
|
||||
elif db.mode == "sqlite":
|
||||
async with aiosqlite.connect(db.file) as conn:
|
||||
async with conn.execute("SELECT * FROM users WHERE ? = ?", (arg,type)) as cursor:
|
||||
async with conn.execute("SELECT * FROM users WHERE ? = ?", (type, arg)) as cursor:
|
||||
return await cursor.fetchone()
|
||||
|
||||
def download_audio(video_url: str, output_folder: str) -> str:
|
||||
@@ -175,14 +175,16 @@ async def login_endpoint(req: Request):
|
||||
body = await req.json()
|
||||
#print(body)
|
||||
try:
|
||||
user_data = await fetch_user_info(body["email"])
|
||||
user_data = await fetch_user_info(body["email"], "email")
|
||||
if (user_data is None):
|
||||
print("User doesn't exist")
|
||||
raise HTTPException(status_code=401, detail="User doesn't exist")
|
||||
else:
|
||||
pwd = user_data.get("password")
|
||||
if (bcrypt.checkpw(body["password"].encode(), user_data.get("password").encode())):
|
||||
return user_data
|
||||
else:
|
||||
print("Wrong password")
|
||||
raise HTTPException(status_code=401, detail="Wrong password")
|
||||
except KeyError:
|
||||
raise HTTPException(status_code=400)
|
||||
|
||||
Reference in New Issue
Block a user