[core] Not all hood routes need authentication

This commit is contained in:
maike 2020-07-09 03:09:48 +02:00 committed by dl6tom
parent 023f0c5a46
commit cf5acb144f

View file

@ -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: try:
hood = await Hood.objects.get(id=hood_id) hood = await Hood.objects.get(id=hood_id)
except NoMatch: except NoMatch:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND) 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: try:
await AdminHoodRelation.objects.get(admin=admin, hood=hood) await AdminHoodRelation.objects.get(admin=admin, hood=hood)
except NoMatch: except NoMatch: