Bugfix: Why did the admin sidebar show 'GUEST' role and Space Manage...
Documentation for Sessions
🐛 Bugfix: Why did the admin sidebar show 'GUEST' role and Space Manage...
Date: 2026-02-11
Time: 12:54:53 UTC
Session: gspace1-105.6
Agent: backend
Confidence: 97%
Status: ✅ Documented
📋 Decision Context
Question:
Why did the admin sidebar show 'GUEST' role and Space Management show empty?
Task: Session 105: Fix GUEST role and empty Space/User Management
🎯 Decision Made
Chosen:
Two root causes: (1) Backend sends roles:string[] but auth-ui User expects role:string. Fixed by normalizing in setAuthState(). (2) Space Management called GET /api/spaces/me which returns ONE space for current user, not all spaces. Created GET /api/admin/spaces and /api/admin/users endpoints that query MongoDB directly for full platform listing.
Options Considered:
- Normalize role in auth-ui setAuthState (chosen)
- Change backend to send both role and roles
- Change auth-ui User type to use roles array
💭 Reasoning
The backend BackendAuthService.toUserProfile() returns {roles: ['developer']} but the auth-ui User interface expects {role: 'developer'}. The auth-ui userRole computed defaults to 'guest' when role is undefined. For spaces/users, the existing endpoints are scoped to a single user's data. Admin views need platform-wide listing which requires direct MongoDB queries. Added both to the AdminStatsService since it already has the connection.
📁 Files Involved
libs/libs-ui/auth-ui/src/lib/services/auth.service.tsapis/backend-api/src/app/admin/admin-stats.service.tsapis/backend-api/src/app/admin/admin-stats.controller.tsapps/gograb-admin/src/app/features/space-management/space-management.component.tsapps/gograb-admin/src/app/features/user-management/user-management.component.ts
🔗 Related
- Decision ID:
dev_1770814493170_coe5b1j - Session: 105
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation