Добавил эндпоинт на проверку пароля
This commit is contained in:
parent
49cd5fe894
commit
2d41c02592
3 changed files with 26 additions and 2 deletions
|
@ -29,6 +29,11 @@ class UserNotFoundException(BlackPhoenixException):
|
|||
detail = "Юзер не найден"
|
||||
|
||||
|
||||
class PasswordAlreadyInUseException(BlackPhoenixException):
|
||||
status_code = status.HTTP_409_CONFLICT
|
||||
detail = "Пароль уже занят"
|
||||
|
||||
|
||||
class UserMustConfirmEmailException(BlackPhoenixException):
|
||||
status_code = status.HTTP_409_CONFLICT
|
||||
detail = "Сначала подтвердите почту"
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
from random import randrange
|
||||
|
||||
from fastapi import APIRouter, Depends, status
|
||||
|
||||
from app.config import settings
|
||||
from app.exceptions import UserNotFoundException
|
||||
from app.exceptions import UserNotFoundException, PasswordAlreadyInUseException
|
||||
from app.users.exceptions import (
|
||||
UserAlreadyExistsException,
|
||||
IncorrectAuthDataException,
|
||||
|
@ -31,6 +33,7 @@ from app.users.schemas import (
|
|||
STokenLogin,
|
||||
SUsers,
|
||||
SConfirmationData,
|
||||
SUserPassword,
|
||||
)
|
||||
from app.tasks.tasks import (
|
||||
send_registration_confirmation_email,
|
||||
|
@ -67,6 +70,17 @@ async def check_existing_user(user_filter: SUserFilter, uow=Depends(UnitOfWork))
|
|||
pass
|
||||
|
||||
|
||||
@router.post(
|
||||
"/check_existing_password",
|
||||
status_code=status.HTTP_200_OK,
|
||||
response_model=None
|
||||
)
|
||||
async def check_existing_password(user_password: SUserPassword):
|
||||
random_int = randrange(10)
|
||||
if random_int > 5:
|
||||
raise PasswordAlreadyInUseException
|
||||
|
||||
|
||||
@router.post(
|
||||
"/register",
|
||||
status_code=status.HTTP_201_CREATED,
|
||||
|
@ -143,7 +157,8 @@ async def get_user(current_user: SUser = Depends(get_current_user)):
|
|||
)
|
||||
async def get_user_avatars_history(user=Depends(get_current_user), uow=Depends(UnitOfWork)):
|
||||
async with uow:
|
||||
return await uow.user.get_user_avatars(user_id=user.id)
|
||||
user_avatars = await uow.user.get_user_avatars(user_id=user.id)
|
||||
return user_avatars
|
||||
|
||||
|
||||
@router.post(
|
||||
|
|
|
@ -98,6 +98,10 @@ class SUserFilter(BaseModel):
|
|||
email: EmailStr | None = None
|
||||
|
||||
|
||||
class SUserPassword(BaseModel):
|
||||
user_password: str = Query(None, min_length=8)
|
||||
|
||||
|
||||
class SConfirmationData(BaseModel):
|
||||
user_id: int
|
||||
username: str
|
||||
|
|
Loading…
Add table
Reference in a new issue