diff --git a/api/kiwi_vpn_api/routers/device.py b/api/kiwi_vpn_api/routers/device.py index 1067fe3..933b9f4 100644 --- a/api/kiwi_vpn_api/routers/device.py +++ b/api/kiwi_vpn_api/routers/device.py @@ -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, )