Commit Graph

5 Commits

Author SHA1 Message Date
dwindown
52b16dce07 Implement collaboration wallets, withdrawals, and app UI flows 2026-02-03 16:03:11 +07:00
dwindown
d6126d1943 Fix admin redirect by using isAdmin from auth context instead of user_metadata.role
The root cause was that ProtectedRoute and Auth.tsx were checking user.user_metadata?.role,
but the admin role is stored in the user_roles table, not in user metadata.

Changes:
- ProtectedRoute: Use isAdmin flag from useAuth context instead of user.user_metadata?.role
- Auth.tsx: Use isAdmin flag for role-based redirect logic
- Remove redundant auth checks from individual admin/member pages (ProtectedRoute handles it)
- Add isAdmin to useEffect dependencies to ensure redirect happens after admin check completes

This fixes the issue where admins were being redirected to /dashboard instead of /admin
after login, because the role check was happening before the async admin role lookup completed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-04 19:04:10 +07:00
gpt-engineer-app[bot]
e5d42d2d1b Changes 2025-12-19 14:13:40 +00:00
gpt-engineer-app[bot]
7f1622613c Changes 2025-12-19 13:07:23 +00:00
gpt-engineer-app[bot]
986c7c6992 Changes 2025-12-19 03:26:31 +00:00