From fa50712c316f777175db5c078c04618600ddfc27 Mon Sep 17 00:00:00 2001 From: muhamad fais aizat Date: Fri, 16 May 2025 17:41:06 +0700 Subject: [PATCH] fix:chek-email --- backend/routes/auth.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/routes/auth.py b/backend/routes/auth.py index 79af6dc7..23be9716 100644 --- a/backend/routes/auth.py +++ b/backend/routes/auth.py @@ -107,9 +107,8 @@ class CekEmail(BaseModel): @auth_router.get("/check-email") async def check_email(email: str = Query(..., description="Email yang akan dicek")): try: - with conn.begin(): # transaksi otomatis - query = select(users).where(users.c.email == email) - result = conn.execute(query).fetchone() + query = select(users).where(users.c.email == email) + result = conn.execute(query).fetchone() if result: return {"message": "true"} @@ -117,7 +116,11 @@ async def check_email(email: str = Query(..., description="Email yang akan dicek raise HTTPException(status_code=400, detail="false") except SQLAlchemyError as e: + try: + conn.rollback() # Jika sebelumnya ada transaksi yang belum selesai + except: + pass raise HTTPException(status_code=500, detail=f"Database error: {str(e)}") except Exception as e: - raise HTTPException(status_code=500, detail=f"Unexpected error: {str(e)}") \ No newline at end of file + raise HTTPException(status_code=500, detail=f"Unexpected error: {str(e)}")