diff --git a/app/routers/auth.py b/app/routers/auth.py index f6d123f..e85d4cb 100644 --- a/app/routers/auth.py +++ b/app/routers/auth.py @@ -7,7 +7,7 @@ from fastapi.responses import StreamingResponse from app.models import User -from app.types.pydantic_models import Token +from app.types.pydantic_models import Token, Enable2FA from app.utils import authenticate_user, generate_user_token from app.security import TwoFactorAuth from app.dependencies import ( @@ -96,7 +96,7 @@ async def login_with_2fa( @router.post("/2fa/enable/") async def enable_2fa( current_user: Annotated[User, Depends(get_current_frontend_user)], -): +) -> Enable2FA: secret_key = await TwoFactorAuth.get_or_create_secret_key(current_user.id) two_factor_auth = TwoFactorAuth(current_user.id, secret_key) @@ -105,10 +105,10 @@ async def enable_2fa( } -@router.get("/2fa/generate-qrcode/") +@router.post("/2fa/generate-qrcode/") async def generate_qrcode( form_data: Annotated[OAuth2PasswordRequestForm, Depends()], -): +) -> bytes: current_user = await authenticate_user(form_data.username, form_data.password) if not current_user: raise HTTPException( diff --git a/app/types/pydantic_models.py b/app/types/pydantic_models.py index f2f6f5d..9003be1 100644 --- a/app/types/pydantic_models.py +++ b/app/types/pydantic_models.py @@ -323,3 +323,7 @@ class TeamModel(BaseModel): outros_profissionais: List[str] ultima_atualizacao_profissionais: date ultima_atualizacao_infos_equipe: date + + +class Enable2FA(BaseModel): + secret_key: str \ No newline at end of file