From a88168b8d4189f3c2cdc4ad830c4904966bdb4e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Thu, 31 Mar 2022 16:48:52 +0000 Subject: [PATCH] fix: device creation --- api/kiwi_vpn_api/routers/device.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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, )