## Summary - Add `is_admin` column to users table with Alembic migration and a `require_admin` FastAPI dependency that protects all admin-facing write endpoints (games, pokemon, evolutions, bosses, routes CRUD) - Expose admin status to frontend via user API and update AuthContext to fetch/store `isAdmin` after login - Make navigation menu auth-aware (different links for logged-out, logged-in, and admin users) and protect frontend routes with `ProtectedRoute` and `AdminRoute` components, preserving deep-linking through redirects - Fix test reliability: `drop_all` before `create_all` to clear stale PostgreSQL enums from interrupted test runs - Fix test auth: add `admin_client` fixture and use valid UUID for mock user so tests pass with new admin-protected endpoints ## Test plan - [x] All 252 backend tests pass - [ ] Verify non-admin users cannot access admin write endpoints (games, pokemon, evolutions, bosses CRUD) - [ ] Verify admin users can access admin endpoints normally - [ ] Verify navigation shows correct links for logged-out, logged-in, and admin states - [ ] Verify `/admin/*` routes redirect non-admin users with a toast - [ ] Verify `/runs/new` and `/genlockes/new` redirect unauthenticated users to login, then back after auth 🤖 Generated with [Claude Code](https://claude.com/claude-code) Reviewed-on: #67 Co-authored-by: Julian Tabel <juliantabel.jt@gmail.com> Co-committed-by: Julian Tabel <juliantabel.jt@gmail.com>
1.2 KiB
1.2 KiB
title, status, type, priority, created_at, updated_at, parent
| title | status | type | priority | created_at | updated_at | parent |
|---|---|---|---|---|---|---|
| Add is_admin column to users table | completed | task | normal | 2026-03-21T10:06:19Z | 2026-03-21T10:10:38Z | nuzlocke-tracker-ce4o |
Add an is_admin boolean column (default false) to the users table via an Alembic migration.
Checklist
- Create Alembic migration adding
is_admin: Mapped[bool]column withserver_default="false" - Update
Usermodel inbackend/src/app/models/user.py - Run migration and verify column exists
- Seed a test admin user (or document how to set
is_admin=truevia SQL)
Files to change
backend/src/app/models/user.py— addis_adminfieldbackend/src/app/alembic/versions/— new migration
Summary of Changes
Added is_admin boolean column to the users table:
- Migration:
p7e8f9a0b1c2_add_is_admin_to_users.pyadds the column withserver_default='false' - Model: Updated
Usermodel withis_admin: Mapped[bool]field
Setting admin via SQL
To promote a user to admin:
UPDATE users SET is_admin = true WHERE email = 'admin@example.com';
Or by user ID:
UPDATE users SET is_admin = true WHERE id = '<uuid>';