Piotr Domański
e2af49046c
All checks were successful
Python lint and test / linttest (push) Successful in 5m30s
19 lines
652 B
Python
19 lines
652 B
Python
from fastapi import HTTPException
|
|
|
|
from ..domain.user import User as DBUser
|
|
from ..model.user import CreateUserPayload, User
|
|
from .base import BaseController
|
|
|
|
|
|
class CreateUser(BaseController):
|
|
async def call(self, content: CreateUserPayload) -> User:
|
|
async with self.async_session.begin() as session:
|
|
try:
|
|
user = await DBUser.create(
|
|
session,
|
|
content.username,
|
|
content.password,
|
|
)
|
|
return User.from_orm(user)
|
|
except AssertionError as e:
|
|
raise HTTPException(status_code=400, detail=e.args[0])
|