66from fastapi .security import OAuth2PasswordRequestForm
77from sqlalchemy .ext .asyncio import AsyncSession
88
9- from .. import auth , db , models , schemas
10- from .. import supabase
9+ from .. import auth , db , models , schemas , supabase
1110
1211router = APIRouter (prefix = "/api/auth" , tags = ["auth" ])
1312
@@ -23,7 +22,7 @@ async def register_user(
2322 try :
2423 supabase .signup (user_in .username , user_in .password )
2524 except Exception as exc :
26- raise HTTPException (status_code = 400 , detail = str (exc ))
25+ raise HTTPException (status_code = 400 , detail = str (exc )) from exc
2726
2827 q = await session .execute (
2928 models .User .__table__ .select ().where (models .User .username == user_in .username )
@@ -52,7 +51,7 @@ async def login_for_access_token(
5251 # token_response may contain access_token and refresh_token
5352 return {"access_token" : token_response .get ("access_token" ), "token_type" : "bearer" }
5453 except Exception as exc :
55- raise HTTPException (status_code = 400 , detail = str (exc ))
54+ raise HTTPException (status_code = 400 , detail = str (exc )) from exc
5655
5756 q = await session .execute (
5857 models .User .__table__ .select ().where (models .User .username == form_data .username )
0 commit comments