minor bugs

This commit is contained in:
Jörn-Michael Miehe 2022-03-28 23:11:58 +00:00
parent e4548aab3a
commit cd3cccb540

View file

@ -76,24 +76,26 @@ async def get_current_user(
status.HTTP_403_FORBIDDEN: Responses.NEEDS_ADMIN,
status.HTTP_409_CONFLICT: Responses.ENTRY_EXISTS,
},
response_model=User,
response_model=UserRead,
)
async def add_user(
user: UserCreate,
_: User = Depends(get_current_user_if_admin),
):
) -> User:
"""
POST ./: Create a new user in the database.
"""
# actually create the new user
new_user = User.create(**user.dict())
new_user.set_capabilities([UserCapabilityType.login])
# fail if creation was unsuccessful
if new_user is None:
raise HTTPException(status_code=status.HTTP_409_CONFLICT)
new_user.set_capabilities([UserCapabilityType.login])
new_user.update()
# return the created user on success
return new_user