Repository navigation
fix(dashboard): gate background queries on the permission their endpoint requires - #1445
Merged
iammukeshm merged 4 commits intoNov 3, 2026
Conversation
…int requires The notification bell, the chat unread pill and the overview usage card queried their endpoints for every user, so a role without the permission got a 403 per poll and an error line in the API log. Gate each query on the endpoint's permission, hide the topbar pieces without it and show a no-access state on the overview usage card. Fixes fullstackhero#1444
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
iammukeshm
approved these changes
Nov 3, 2026
iammukeshm
left a comment
Member
There was a problem hiding this comment.
This is the right pattern, and documenting it in dashboard.md means new topbar or overview queries will follow it. Good catch on refetch() ignoring enabled, and I like that the spec proves no request fires instead of only checking the UI. Thanks!
iammukeshm
added a commit
to fullstackhero/docs
that referenced
this pull request
Nov 3, 2026
…on (#273) Docs for fullstackhero/dotnet-starter-kit#1445. Co-authored-by: iammukeshm <iammukeshm@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1444
What
The dashboard queried three endpoints for every signed-in user, whatever their permissions. A role without the permission got a 403 on each poll, and the API logged an error line for each one. This gates each query on the permission its endpoint enforces:
RequirePermission)GET /notifications/unread-countPermissions.Notifications.Inbox.ViewGET /chat/channelsPermissions.Chat.Channels.View/chat)GET /billing/usagePermissions.Billing.ViewIt follows the pattern already used for
/auditson the overview and activity pages:enabled: permissionsHydrated && user.permissions.includes(...). The overview's refresh button callsrefetch(), which ignoresenabled, so that call carries the same gate.Not changed on purpose: the page-local callers of the same endpoints (
/chatrail and page,/subscription). They sit behind nav items gated on the same permission, and the dashboard has no per-route guards by design (frontend/dashboard.md).Tests
tests/layout/permission-gated-queries.spec.ts: without the permissions, none of the three endpoints is requested (counted after the page proves permissions hydrated) and the UI pieces are hidden or show no-access; with them, each endpoint is requested and its UI renders.installShellMocksused to grant no permissions, so after this change the shell's own queries would have silently stopped firing in every spec. It now grantsSHELL_PERMISSIONS(the three Basic-role grants above), which keeps the existing overview, chat and billing specs on the real query path. Specs that test a missing permission already re-mock/identity/permissions.Mutation gate: with the
src/change reverted, the "without the permissions" test fails with each endpoint requested once ("/api/v1/billing/usage": 1,"/api/v1/chat/channels": 1,"/api/v1/notifications/unread-count": 1); with it, both tests pass.Local runs:
npx tsc -b --noEmitclean,npm run lint0 errors (12 existing warnings, none in touched files), full dashboard suite 163 passed and 2 failed. The 2 failures are the first test of eachchat.spec.tsdescribe on a cold Vite server. They fail the same way with this change reverted (tests/chat --repeat-each=4: 3 failed and 17 passed on both trees), and they pass on a re-run.Also updates
.agents/rules/frontend/dashboard.mdwith the rule for queries mounted outside their own page.