From ce73ad668446b5b76660118539bdd940d24177c1 Mon Sep 17 00:00:00 2001 From: urec56 Date: Sat, 13 Jul 2024 15:13:58 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BF=D0=BE=D0=B4=D1=82=D0=B2=D0=B5=D1=80=D0=B6?= =?UTF-8?q?=D0=B4=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D0=BE=D1=87=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/users/router.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/users/router.py b/app/users/router.py index aa1c6d6..97cdeb9 100644 --- a/app/users/router.py +++ b/app/users/router.py @@ -132,7 +132,7 @@ async def resend_email_verification(user: SUser = Depends(get_current_user)): @router.get( - "/email_verification/{user_code}", + "/email_verification/link/{user_code}", status_code=status.HTTP_200_OK, response_model=SEmailVerification, ) @@ -149,6 +149,23 @@ async def email_verification(user_code: str, uow=Depends(UnitOfWork)): return {"email_verification": True} +@router.get( + "/email_verification/code/{user_code}", + status_code=status.HTTP_200_OK, + response_model=SEmailVerification, +) +async def email_verification(user_code: str, user: SUser = Depends(get_current_user), uow=Depends(UnitOfWork)): + redis_session = get_redis_session() + async with uow: + verification_code = await RedisService.get_verification_code(redis=redis_session, user_id=user.id) + if verification_code != user_code: + raise WrongCodeException + + await uow.user.change_data(user_id=user.id, role=settings.VERIFICATED_USER) + await uow.commit() + return {"email_verification": True} + + @router.post( "/login", status_code=status.HTTP_200_OK,