refactor(auth): add withAdmin() wrapper for admin API routes #68

Merged
varutasu merged 1 commit from refactor/with-admin-wrapper into main 2026-06-02 13:42:22 -04:00
varutasu commented 2026-06-02 12:02:49 -04:00 (Migrated from github.com)

Summary

  • Add withAdmin(handler) to lib/permission-middleware.js — inner handler receives (req, res, user) after auth gates
  • Sweep 4 admin routes off duplicated inline user.role !== 'admin' checks
  • Update auth/api-routes rules; 3 new unit tests (56 total)

Test plan

  • npm run test:run — 56/56 pass
  • npm run lint — clean

Made with Cursor

## Summary - Add `withAdmin(handler)` to `lib/permission-middleware.js` — inner handler receives `(req, res, user)` after auth gates - Sweep 4 admin routes off duplicated inline `user.role !== 'admin'` checks - Update auth/api-routes rules; 3 new unit tests (56 total) ## Test plan - [x] `npm run test:run` — 56/56 pass - [x] `npm run lint` — clean Made with [Cursor](https://cursor.com)
vercel[bot] commented 2026-06-02 12:02:51 -04:00 (Migrated from github.com)

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tcg-vault Ready Ready Preview, Comment Jun 2, 2026 4:03pm

Request Review

[vc]: #EyeLZm+RfPSLXRXrdgmDaU4AEsC8Hue3DlYEXOz3gTc=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJ0Y2ctdmF1bHQiLCJwcm9qZWN0SWQiOiJwcmpfRjZXOEVvRkd3Y0g3aWVGcnRvRlNlOXdVVkFhNSIsImluc3BlY3RvclVybCI6Imh0dHBzOi8vdmVyY2VsLmNvbS9yYW5kYWxsLXN0aWxsd2VsbHMtcHJvamVjdHMvdGNnLXZhdWx0L0RhajdSZ2pvZnpxVEQzeDczYWpCYTJDa2M3Qm8iLCJwcmV2aWV3VXJsIjoidGNnLXZhdWx0LWdpdC1yZWZhY3Rvci13aXRoLTQwMDIyYS1yYW5kYWxsLXN0aWxsd2VsbHMtcHJvamVjdHMudmVyY2VsLmFwcCIsIm5leHRDb21taXRTdGF0dXMiOiJERVBMT1lFRCIsImxpdmVGZWVkYmFjayI6eyJyZXNvbHZlZCI6MCwidW5yZXNvbHZlZCI6MCwidG90YWwiOjAsImxpbmsiOiJ0Y2ctdmF1bHQtZ2l0LXJlZmFjdG9yLXdpdGgtNDAwMjJhLXJhbmRhbGwtc3RpbGx3ZWxscy1wcm9qZWN0cy52ZXJjZWwuYXBwIn0sInJvb3REaXJlY3RvcnkiOm51bGx9XSwicmVxdWVzdFJldmlld1VybCI6Imh0dHBzOi8vdmVyY2VsLmNvbS92ZXJjZWwtYWdlbnQvcmVxdWVzdC1yZXZpZXc/b3duZXI9dmFydXRhc3UmcmVwbz10Y2ctdmF1bHQmcHI9NjgifQ== The latest updates on your projects. Learn more about [Vercel for GitHub](https://vercel.link/github-learn-more). | Project | Deployment | Actions | Updated (UTC) | | :--- | :----- | :------ | :------ | | [tcg-vault](https://vercel.com/randall-stillwells-projects/tcg-vault) | ![Ready](https://vercel.com/static/status/ready.svg) [Ready](https://vercel.com/randall-stillwells-projects/tcg-vault/Daj7RgjofzqTD3x73ajBa2Ckc7Bo) | [Preview](https://tcg-vault-git-refactor-with-40022a-randall-stillwells-projects.vercel.app), [Comment](https://vercel.live/open-feedback/tcg-vault-git-refactor-with-40022a-randall-stillwells-projects.vercel.app?via=pr-comment-feedback-link) | Jun 2, 2026 4:03pm | <a href="https://vercel.com/vercel-agent/request-review?owner=varutasu&repo=tcg-vault&pr=68" rel="noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://agents-vade-review.vercel.sh/request-review-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://agents-vade-review.vercel.sh/request-review-light.svg"><img src="https://agents-vade-review.vercel.sh/request-review-light.svg" alt="Request Review"></picture></a>
github-actions[bot] commented 2026-06-02 12:03:07 -04:00 (Migrated from github.com)

Pipeline Health

Build + CI gates

Gate Status
Vercel build (Preview) pass
CI: Lint pass
CI: Schema map fresh skipped
Preview smoke pass
Visual diff ⏭ skipped or pending

Build runs on Vercel; this CI runs lint and schema-map drift only (no duplicate build).

Role reports

Role Status
Reviewer report pending
A11y audit pending
Design system audit pending

See individual comments above for details. This rollup updates automatically.

<!-- pipeline-rollup --> ## Pipeline Health ### Build + CI gates | Gate | Status | | --- | --- | | Vercel build (Preview) | ✅ pass | | CI: Lint | ✅ pass | | CI: Schema map fresh | ❌ skipped | | Preview smoke | ✅ pass | | Visual diff | ⏭ skipped or pending | _Build runs on Vercel; this CI runs lint and schema-map drift only (no duplicate build)._ ### Role reports | Role | Status | | --- | --- | | Reviewer report | ⏳ pending | | A11y audit | ⏳ pending | | Design system audit | ⏳ pending | See individual comments above for details. This rollup updates automatically.
Sign in to join this conversation.
No description provided.