Developers/Workflow/View As Role Switching
View As Role Switching
Objective
Allow a logged superadmin to navigate the app as another role while keeping the View as control always available.
Scope
- Frontend: avatar popup menu in main page header. - Roles available in View as: superadmin, admin, moderator, user. - Applies only when the authenticated account has role code superadmin.
Behavior
- A new section "View as" is shown in the user avatar menu. - Each role option shows a marker on the left:
- "√" for the active effective role. - blank marker for inactive options.
- Default state for superadmin login:
- superadmin starts selected with "√".
- On selection:
- superadmin -> opens Super Admin panel. - admin -> opens Admin panel. - moderator -> opens Moderator panel. - user -> navigates to Home.
- The "View as" section remains visible after switching, allowing back-and-forth role simulation without logging out.
Access Model
- Authentication roles from backend remain unchanged. - View as creates an effective role in frontend navigation only. - Panel access checks use the effective role for navigation guards.
UX Notes
- This is role simulation for navigation and UI surface. - Logged identity/session remains the same authenticated superadmin user.
Technical Notes
- Primary implementation file: App.tsx - Added i18n keys for menu labels:
- actionViewAs - actionUser