Fix group none error
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Madis Mägi 2024-08-28 11:22:33 +03:00
parent 8d296286f1
commit b9364f0e3d
2 changed files with 3 additions and 3 deletions

View File

@ -33,7 +33,7 @@ def view_inventory_view(item_id):
template = "inventory_view_public.html"
redirect_url = urllib.parse.quote_plus(request.full_path)
else:
can_audit = "k-space:janitors" in user["groups"]
can_audit = "k-space:janitors" in user.get("groups", [])
can_edit = check_edit_permission(item_id)
is_using = item_user and item_user == user["username"]
photo_url = get_image_url(item_id)
@ -411,7 +411,7 @@ def view_inventory(slug=None):
else:
fields.append(("inventory.owner.username", "Owner", str))
fields.append(("inventory.user.username", "User", str))
can_audit = "k-space:janitors" in login_user["groups"]
can_audit = "k-space:janitors" in login_user.get("groups", [])
if slug and not public_view:
template = "inventory_pick.html"
if request.path.startswith("/m/inventory/clone-with-slug"):

View File

@ -21,7 +21,7 @@ def login_required(_f=None, *, groups=[]):
user = read_user()
if not user:
return do_login()
if groups and not any(group in groups for group in user["groups"]):
if groups and not any(group in groups for group in user.get("groups", [])):
return "not allowed", 401
return f(*args, **kwargs)
return decorated_function