Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating Docs #215

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading