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>
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>
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>
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
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>
- 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>
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>
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` boolean column (default false) via Alembic migration
for role-based access control.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>