сделал заготовку под регистрацию
This commit is contained in:
parent
be972cd532
commit
d2d3bf8c21
@ -42,4 +42,3 @@ async def auth_user(
|
|||||||
)
|
)
|
||||||
|
|
||||||
return {"access_token": access_token, "refresh_token": None}
|
return {"access_token": access_token, "refresh_token": None}
|
||||||
|
|
||||||
|
|||||||
22
api/app/controllers/register_routes.py
Normal file
22
api/app/controllers/register_routes.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from fastapi import APIRouter, Depends, HTTPException, Response, status
|
||||||
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
|
from app.database.session import get_db
|
||||||
|
from app.domain.entities.register import RegisterEntity
|
||||||
|
from app.infrastructure.auth_service import AuthService
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
|
@router.post(
|
||||||
|
"/register/",
|
||||||
|
response_model=dict,
|
||||||
|
summary="Регистрация пользователя",
|
||||||
|
description="Производит регистрацию пользователя в системе.",
|
||||||
|
)
|
||||||
|
async def register_user(
|
||||||
|
response: Response,
|
||||||
|
user_data: RegisterEntity,
|
||||||
|
db: AsyncSession = Depends(get_db)
|
||||||
|
):
|
||||||
|
return {}
|
||||||
@ -2,6 +2,6 @@ from pydantic import BaseModel, Field
|
|||||||
|
|
||||||
|
|
||||||
class AuthEntity(BaseModel):
|
class AuthEntity(BaseModel):
|
||||||
login: str = Field(..., example="user@example.com")
|
login: str = Field(..., example='user@example.com')
|
||||||
password: str = Field(..., min_length=5, example="strongpassword")
|
password: str = Field(..., min_length=5, example='strongpassword')
|
||||||
|
|
||||||
|
|||||||
12
api/app/domain/entities/register.py
Normal file
12
api/app/domain/entities/register.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
|
||||||
|
class RegisterEntity(BaseModel):
|
||||||
|
first_name: str = Field(..., example='Ivan')
|
||||||
|
last_name: str = Field(..., example='Ivanov')
|
||||||
|
patronymic: Optional[str] = Field(None, example='Ivanov')
|
||||||
|
role_id: int = Field(..., example=1)
|
||||||
|
login: str = Field(..., example='user@example.com')
|
||||||
|
password: str = Field(..., min_length=5, example='strongpassword')
|
||||||
@ -2,6 +2,7 @@ from fastapi import FastAPI
|
|||||||
from starlette.middleware.cors import CORSMiddleware
|
from starlette.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
from app.controllers.auth_routes import router as auth_router
|
from app.controllers.auth_routes import router as auth_router
|
||||||
|
from app.controllers.register_routes import router as register_router
|
||||||
from app.settings import settings
|
from app.settings import settings
|
||||||
|
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ def start_app():
|
|||||||
)
|
)
|
||||||
|
|
||||||
api_app.include_router(auth_router, prefix=settings.APP_PREFIX)
|
api_app.include_router(auth_router, prefix=settings.APP_PREFIX)
|
||||||
|
api_app.include_router(register_router, prefix=settings.APP_PREFIX)
|
||||||
|
|
||||||
return api_app
|
return api_app
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user