Skip to content

Commit

Permalink
Merge pull request #215 from prefeitura-rio/feat/2fa
Browse files Browse the repository at this point in the history
Creating Docs
  • Loading branch information
TanookiVerde committed Aug 31, 2024
2 parents 38ad345 + 9dec108 commit b907042
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)

Expand All @@ -108,7 +108,7 @@ async def enable_2fa(
@router.get("/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(
Expand Down
4 changes: 4 additions & 0 deletions app/types/pydantic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b907042

Please sign in to comment.