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" template = "inventory_view_public.html"
redirect_url = urllib.parse.quote_plus(request.full_path) redirect_url = urllib.parse.quote_plus(request.full_path)
else: 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) can_edit = check_edit_permission(item_id)
is_using = item_user and item_user == user["username"] is_using = item_user and item_user == user["username"]
photo_url = get_image_url(item_id) photo_url = get_image_url(item_id)
@ -411,7 +411,7 @@ def view_inventory(slug=None):
else: else:
fields.append(("inventory.owner.username", "Owner", str)) fields.append(("inventory.owner.username", "Owner", str))
fields.append(("inventory.user.username", "User", 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: if slug and not public_view:
template = "inventory_pick.html" template = "inventory_pick.html"
if request.path.startswith("/m/inventory/clone-with-slug"): if request.path.startswith("/m/inventory/clone-with-slug"):

View File

@ -21,7 +21,7 @@ def login_required(_f=None, *, groups=[]):
user = read_user() user = read_user()
if not user: if not user:
return do_login() 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 "not allowed", 401
return f(*args, **kwargs) return f(*args, **kwargs)
return decorated_function return decorated_function