Skip to content

Commit

Permalink
feat: create /auth/is_need_to_fill_profile endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dantetemplar committed Feb 12, 2024
1 parent 66305e4 commit 3a6d005
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/api/auth/routes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import random

from fastapi import HTTPException
from starlette.background import BackgroundTasks

from src.api.auth import router
Expand Down Expand Up @@ -37,6 +38,17 @@ async def is_user_exists(email: str = None, telegram_id: str = None) -> bool:
return await auth_repository.is_user_registered(email, telegram_id)


@router.get("/is_need_to_fill_profile")
async def is_need_to_fill_profile(telegram_id: str):
participant_repository = Dependencies.get(AbstractParticipantRepository)
auth_repository = Dependencies.get(AbstractAuthRepository)
is_registered = await auth_repository.is_user_registered(telegram_id=telegram_id)
if not is_registered:
raise HTTPException(status_code=404, detail="User not found")
participant_id = await participant_repository.get_participant_id(telegram_id)
return await participant_repository.is_need_to_fill_profile(participant_id)


@router.post("/validate_code")
async def validate_code(
email: str,
Expand Down
2 changes: 1 addition & 1 deletion src/repositories/auth/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, storage: AbstractSQLAlchemyStorage):
def _create_session(self) -> AsyncSession:
return self.storage.create_session()

async def is_user_registered(self, email: str, telegram_id: str | None) -> bool:
async def is_user_registered(self, email: str | None = None, telegram_id: str | None = None) -> bool:
async with self._create_session() as session:
if email is None and telegram_id is None:
return False
Expand Down

0 comments on commit 3a6d005

Please sign in to comment.