Skip to content

feat: add admin panel with Bouncer authorization and user CRUD API - #2

Open
n3n wants to merge 7 commits into
kmitl-intertia-reactfrom
monterrey-v1
Open

feat: add admin panel with Bouncer authorization and user CRUD API#2
n3n wants to merge 7 commits into
kmitl-intertia-reactfrom
monterrey-v1

Conversation

@n3n

@n3n n3n commented Jul 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Integrates @adonisjs/bouncer for role-based access control with an AdminPolicy and abilities, guarded by InitializeBouncerMiddleware
  • Adds a react-admin-powered /admin page backed by @aginix/vulcan-data-provider and a REST API (/api/users) for full user CRUD
  • Updates User model with the Filterable mixin, adds per-page Inertia layout support in app.tsx, and registers new routes, controllers, and policies in AdonisJS config files

Test plan

  • Log in as an admin user and verify /admin renders the react-admin UI
  • Confirm non-admin users are denied access to /admin (Bouncer policy check)
  • Test user list, create, update, and delete via the admin panel
  • Verify normal pages (home, login) are unaffected

🤖 Generated with Claude Code

n3n and others added 7 commits July 9, 2026 23:32
Integrates react-admin with @adonisjs/bouncer for role-based access control,
adds a REST API for user management, and wires up per-page Inertia layouts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add single-file List/Show/Create/Edit components for the users resource
and wire them into the Admin resource. Exempt /api routes from CSRF so the
react-admin data provider can call the user API.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…i i18n

- Add `role` column to users; gate /admin and the users API behind AdminPolicy
  (admins only) via Bouncer — verified: non-admin gets 403, admin 200
- Fix broken AdminPolicy (dropped non-existent #models/admin import) and
  implement viewAdmin/manageUsers abilities
- Add VineJS create/update validators + reusable database-unique rule
  (email format & uniqueness, password length, role enum) → 422 on bad input
- Serve react-admin SPA under /admin/* with matching basename so deep links
  and refreshes resolve; fix duplicate-dot `api.` route name
- Add Thai i18nProvider (English fallback) and pass the MUI theme to <Admin>
- Seed admin@kmitl.ac.th (admin) and demo@kmitl.ac.th (user), password "password"

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Wrap <Admin> in HashRouter so all admin navigation lives in the URL fragment
(/admin#/users) — deep links and refreshes never hit the server, and
react-admin reuses this router instead of mounting its own BrowserRouter.
Add react-router-dom as a direct dependency.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Revert to react-admin's default router and drop the react-router-dom
dependency that was only used for HashRouter.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant