Fix groups checking
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Madis Mägi 2023-08-10 19:42:18 +03:00
parent fd74c294b1
commit b0d0505000

View File

@ -35,15 +35,16 @@ async def view_doorboy_uids(request):
if not key or key not in [DOORBOY_SECRET_FLOOR, DOORBOY_SECRET_WORKSHOP]:
return text("how about no")
groups = []
if key == DOORBOY_SECRET_FLOOR:
group = FLOOR_ACCESS_GROUP
elif key == DOORBOY_SECRET_WORKSHOP:
group = WORKSHOP_ACCESS_GROUP
if not group:
groups.append(FLOOR_ACCESS_GROUP)
if key == DOORBOY_SECRET_WORKSHOP:
groups.append(WORKSHOP_ACCESS_GROUP)
if not groups:
return "fail", 500
async with httpx.AsyncClient() as client:
r = await client.post(CARD_URI, json={
"groups": [group]
"groups": groups
}, headers={
"Content-Type": "application/json",
"Authorization": f"Basic {INVENTORY_API_KEY}"