Compare commits
2 commits
008f0b2cf6
...
583d1de06a
| Author | SHA1 | Date | |
|---|---|---|---|
| 583d1de06a | |||
| a88168b8d4 |
2 changed files with 6 additions and 3 deletions
|
|
@ -36,7 +36,7 @@ class Responses:
|
|||
"content": None,
|
||||
}
|
||||
NEEDS_PERMISSION = {
|
||||
"description": "You're not allowed that operation",
|
||||
"description": "Operation not permitted",
|
||||
"content": None,
|
||||
}
|
||||
ENTRY_EXISTS = {
|
||||
|
|
|
|||
|
|
@ -36,9 +36,13 @@ async def add_device(
|
|||
if not current_user.can_create(Device, owner):
|
||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN)
|
||||
|
||||
# fail if owner doesn't exist
|
||||
if owner is None:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)
|
||||
|
||||
# create the new device
|
||||
new_device = Device.create(
|
||||
owner=current_user,
|
||||
owner=owner,
|
||||
device=device,
|
||||
)
|
||||
|
||||
|
|
@ -57,7 +61,6 @@ async def add_device(
|
|||
status.HTTP_400_BAD_REQUEST: Responses.NOT_INSTALLED,
|
||||
status.HTTP_401_UNAUTHORIZED: Responses.NEEDS_USER,
|
||||
status.HTTP_403_FORBIDDEN: Responses.NEEDS_PERMISSION,
|
||||
status.HTTP_404_NOT_FOUND: Responses.ENTRY_DOESNT_EXIST,
|
||||
},
|
||||
response_model=User,
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue