feat(dashboard): admin-only "view as" control on my-reviews page #77
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/reviews-view-as"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Admins often sign in to the dashboard with a dedicated admin account that never authors PRs, so their "my reviews" page comes up empty. This adds an admin-only "view as" control to
/reviews:GET /reviews?as=<email>scopes the list to that identity, with a banner and a "view your own" escape link.users.default_view_emailcolumn (migration 000010) stores a preferred identity; "Save as my default" / "Clear default" buttons manage it via admin-gatedPOST /reviews/view-as. Saving your own email normalizes to "no preference".Resolution order for admins:
?as=param → saved default → own email.Non-admins are unaffected:
effectiveReviewEmailignores both the param and any stored preference unless the session is in the admin group, so a regular user cannot browse someone else's review list. Admins can already see every review via/admin/reviews, so this adds no new exposure.Includes table-driven tests for the resolution logic, including the non-admin lockout cases.
gofmt,go vet,go build, andgo test -race ./...all pass.🤖 Generated with Claude Code
Automated review by pr-reviewer v0.36.0 | Safety Check | Claude Sonnet 5 | tracking id
r-607e7b-cd9fbfThis is an AI-generated review and may contain mistakes.
Status: ✅ Completed
✅ Verdict: LGTM — Admin gating is correctly enforced both in the route grouping and in the resolution logic, with no secrets, injection, or breaking changes evident.
Reviewed the diff for the "view as" admin feature.
effectiveReviewEmailcorrectly gates the?as=param and savedDefaultViewEmailbehindisAdmin; non-admins always get their own email regardless of param/stored value. Tests cover the lockout cases explicitly.POST /reviews/view-asroute is registered inside ther.Use(s.RequireAdmin)group, so it's admin-gated at the router level as claimed.NOT NULL DEFAULT ''column with a safe down migration (DROP COLUMN IF EXISTS) — no backfill concerns since default is a constant.SetDefaultViewEmailhandler is light (strings.Contains(email, "@")) but this is just a display preference string with no injection risk (parameterized query) and no sensitive exposure — an admin can already view any user's reviews via/admin/reviews, so this doesn't introduce new exposure as the PR description states.Nothing here looks alarming for a quick safety pass.