Normalize portal kinds before checking feature access
This commit is contained in:
@@ -55,9 +55,15 @@ async def require_portal_access(request: Request, user: dict = Depends(get_curre
|
||||
check(user, "requests" if item.get("kind") == "request" else "issues")
|
||||
elif path.endswith("/items") and request.method == "POST":
|
||||
payload = await request.json()
|
||||
check(user, "new_requests" if isinstance(payload, dict) and payload.get("kind", "request") == "request" else "issues")
|
||||
kind = str(payload.get("kind") or "").strip().lower() if isinstance(payload, dict) else ""
|
||||
check(user, "new_requests" if not kind or kind == "request" else "issues")
|
||||
elif path.endswith(("/items", "/overview")) and request.query_params.get("kind"):
|
||||
check(user, "requests" if request.query_params["kind"] == "request" else "issues")
|
||||
kind = request.query_params["kind"].strip().lower()
|
||||
if not kind:
|
||||
check(user, "requests")
|
||||
check(user, "issues")
|
||||
else:
|
||||
check(user, "requests" if kind == "request" else "issues")
|
||||
else:
|
||||
# Unfiltered lists/overview can include both kinds.
|
||||
check(user, "requests")
|
||||
|
||||
Reference in New Issue
Block a user