From cf5acb144f5129c17fc5b92e3138c2cac955d4f3 Mon Sep 17 00:00:00 2001 From: maike Date: Thu, 9 Jul 2020 03:09:48 +0200 Subject: [PATCH] [core] Not all hood routes need authentication --- kibicara/webapi/hoods/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kibicara/webapi/hoods/__init__.py b/kibicara/webapi/hoods/__init__.py index 29e57e1..815c088 100644 --- a/kibicara/webapi/hoods/__init__.py +++ b/kibicara/webapi/hoods/__init__.py @@ -20,11 +20,15 @@ class BodyHood(BaseModel): ''' -async def get_hood(hood_id: int, admin=Depends(get_admin)): +async def get_hood_unauthorized(hood_id: int): try: hood = await Hood.objects.get(id=hood_id) except NoMatch: raise HTTPException(status_code=status.HTTP_404_NOT_FOUND) + return hood + + +async def get_hood(hood=Depends(get_hood_unauthorized), admin=Depends(get_admin)): try: await AdminHoodRelation.objects.get(admin=admin, hood=hood) except NoMatch: