cool changes

This commit is contained in:
2026-01-15 12:08:11 +00:00
parent c88f3e84ea
commit c9f597b54c
5 changed files with 12 additions and 17 deletions

View File

@@ -53,23 +53,15 @@ class register_model(BaseModel):
async def create_user(req: Request):
body = await req.json()
#body = register_model(**body)
# Auto exceptions give more verbose to Nuxt.
#try:
# body = register_model(**body)
#except ValidationError:
# raise HTTPException(status_code=400, detail="Missing / invalid arguments")
body["password"] = bcrypt.hashpw(body["password"].encode(), bcrypt.gensalt()).decode()
async with db.pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute("INSERT INTO users (`first_name`,`last_name`,`email`,`password`) VALUES (%s,%s,%s,%s)", (body.first_name, body.last_name, body.email, body.password))
await conn.commit()
class login_data(BaseModel):
email: str
password: str
@app.post("/login")
async def login_endpoint(req: Request):
@@ -77,8 +69,6 @@ async def login_endpoint(req: Request):
body = await req.json()
#print(body)
try:
#login = login_data(**body)
# ensure it's only email and password
user_data = await fetch_user_info(body["email"])
if (user_data is None):
raise HTTPException(status_code=401, detail="User doesn't exist")