minor bugs
This commit is contained in:
parent
e4548aab3a
commit
cd3cccb540
1 changed files with 5 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue