diff --git a/backend/app/api/v1/__pycache__/routes_auth.cpython-313.pyc b/backend/app/api/v1/__pycache__/routes_auth.cpython-313.pyc index de9cf88..7590166 100644 Binary files a/backend/app/api/v1/__pycache__/routes_auth.cpython-313.pyc and b/backend/app/api/v1/__pycache__/routes_auth.cpython-313.pyc differ diff --git a/backend/app/api/v1/routes_auth.py b/backend/app/api/v1/routes_auth.py index a60b4a2..ce02087 100644 --- a/backend/app/api/v1/routes_auth.py +++ b/backend/app/api/v1/routes_auth.py @@ -87,21 +87,29 @@ async def refresh_token( db: AsyncIOMotorDatabase = Depends(get_database), ): refresh_token = request.cookies.get("refresh_token") + print(f"🔍 REFRESH DEBUG: Cookie exists: {bool(refresh_token)}") + if not refresh_token: + print("🚨 REFRESH ERROR: No refresh token in cookies") raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, detail="Refresh token not found", ) try: + print(f"🔍 REFRESH DEBUG: Attempting to decode token...") payload = decode_token(refresh_token) + print(f"🔍 REFRESH DEBUG: Token decoded successfully, type={payload.get('type')}") + if payload.get("type") != "refresh": + print(f"🚨 REFRESH ERROR: Wrong token type: {payload.get('type')}") raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid token type", ) user_id = payload.get("sub") + print(f"🔍 REFRESH DEBUG: User ID from token: {user_id}") if not user_id: raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, @@ -138,16 +146,20 @@ async def refresh_token( max_age=settings.jwt_refresh_ttl_days * 24 * 60 * 60, ) + print(f"🔍 REFRESH DEBUG: Refresh successful for user {user_id}") return RefreshResponse( access_token=new_access_token, user_id=user_id, role=user.role.value ) - except Exception: + except Exception as e: + print(f"🚨 REFRESH ERROR: Exception during refresh: {type(e).__name__}: {e}") + import traceback + print(f"Traceback:\n{traceback.format_exc()}") raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, - detail="Invalid refresh token", + detail=f"Invalid refresh token: {str(e)}", )