Spaces:
Runtime error
Runtime error
File size: 975 Bytes
302d8c7 14bfd4c fcfe4b3 6a39039 14bfd4c 6a39039 e1e6967 fcfe4b3 302d8c7 fcfe4b3 d697ce3 6a39039 fcfe4b3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
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")
|