Spaces:
Runtime error
Runtime error
refactor authentication flow by removing unused middleware and simplifying user sign-in response
d697ce3
| from fastapi import APIRouter, HTTPException, status, Request | |
| from src.services import AuthService | |
| from src.schemas import UserSignInSchema, UserSignInResponse | |
| from src.config import logger | |
| class AuthController: | |
| def __init__(self): | |
| self._auth_service = AuthService() | |
| self.api_router = APIRouter(prefix="/auth", tags=["Authentication"]) | |
| self.api_router.add_api_route( | |
| methods=["POST"], | |
| path="/login", | |
| endpoint=self._signin, | |
| response_model=UserSignInResponse, | |
| ) | |
| async def _signin(self, user: UserSignInSchema): | |
| try: | |
| user = await self._auth_service.sign_in(user) | |
| return UserSignInResponse(user_id=str(user["user_id"])) | |
| except HTTPException as e: | |
| raise | |
| except Exception as e: | |
| logger.error(f"Error during implicit signin: {e}") | |
| raise HTTPException(status_code=500, detail="Error during implicit signin") | |