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
## 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
- [x] Verify non-admin users cannot access admin write endpoints (games, pokemon, evolutions, bosses CRUD)
- [x] Verify admin users can access admin endpoints normally
- [x] Verify navigation shows correct links for logged-out, logged-in, and admin states
- [x] Verify `/admin/*` routes redirect non-admin users with a toast
- [x] Verify `/runs/new` and `/genlockes/new` redirect unauthenticated users to login, then back after auth
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Add `is_admin` boolean column (default false) via Alembic migration
for role-based access control.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add require_admin FastAPI dependency that checks is_admin column on users
table. Apply it to all admin-facing write endpoints (games, pokemon,
evolutions, bosses, routes CRUD). Run-scoped endpoints remain protected
by require_auth only since they manage user's own data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add is_admin field to UserResponse schema and update AuthContext to
fetch user profile after login, storing and exposing isAdmin boolean.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Wrap /runs/new and /genlockes/new with ProtectedRoute (requires login)
- Create AdminRoute component that checks isAdmin, redirects non-admins
with a toast notification
- Wrap all /admin/* routes with AdminRoute
- Deep-linking preserved: unauthenticated users redirect to login, then
back to the original protected route after auth
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Navigation links now change based on authentication state:
- Logged out: Home, Runs, Genlockes, Stats
- Logged in: New Run, My Runs, Genlockes, Stats
- Admin: adds Admin link
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The frontend needs to know if the current user is an admin so it can show/hide the Admin nav link and protect admin routes client-side.
Bean: nuzlocke-tracker-5svj
chore: Update beans
If a previous test run was interrupted before teardown, PostgreSQL enum
types persist with stale values, causing create_all to fail. Adding
drop_all first ensures a clean slate.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
After adding require_admin to admin endpoints, tests using
unauthenticated client or auth_client got 401/403. Also fix mock user
ID to be a valid UUID (was "test-user-123", now a proper UUID4).
- Add admin_override and admin_client fixtures to conftest
- Update test_pokemon.py, test_games.py, test_genlocke_boss.py to use
admin_client for write operations on admin endpoints
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Layout now renders different nav links based on auth state. Tests were
using a real AuthProvider which resolved to no user, causing them to
look for "My Runs" and "Admin" links that only appear when logged in.
Mock useAuth to test both logged-out and logged-in-as-admin states.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
TheFurya
merged commit e8ded9184b into develop2026-03-21 11:44:07 +01:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
is_admincolumn to users table with Alembic migration and arequire_adminFastAPI dependency that protects all admin-facing write endpoints (games, pokemon, evolutions, bosses, routes CRUD)isAdminafter loginProtectedRouteandAdminRoutecomponents, preserving deep-linking through redirectsdrop_allbeforecreate_allto clear stale PostgreSQL enums from interrupted test runsadmin_clientfixture and use valid UUID for mock user so tests pass with new admin-protected endpointsTest plan
/admin/*routes redirect non-admin users with a toast/runs/newand/genlockes/newredirect unauthenticated users to login, then back after auth🤖 Generated with Claude Code