HIGH story-role-based-access-control-peer-mentor-005 5 pts
5
Story Points
High
Priority
Role-Based Access Control
Feature

User Story

As a Peer Mentor (Likeperson)
I want to switch between my coordinator and peer mentor roles within the same session without logging out
So that I can register my own peer mentor activities while also performing coordinator duties, using a single app session

Audience Summaries

Many chapters rely on a small pool of committed volunteers who simultaneously serve as both peer mentors and coordinators. Forcing these dual-role users to log out and back in to switch their working context creates direct friction that leads to underreporting of activities—a core metric the platform exists to capture. This high-priority story eliminates that friction by providing a seamless, in-app role switch accessible from the Settings menu. By reducing the effort required to operate in either role, the platform directly supports its primary mission of maximizing participation data completeness.

Improved reporting accuracy enables better resource allocation decisions and strengthens the case for continued organizational investment in the platform.

This story depends on story-role-based-access-control-coordinator-001 and -003 and requires coordination across three functional areas: the role resolution service (Supabase integration), the role state manager, and the role-aware bottom navigation and home screen components. Delivery complexity is moderate-to-high due to the number of UI surfaces that must react to a role switch event—any component that reads the active role must re-render correctly without full navigation. Acceptance criteria include a clean rollback if the user navigates away mid-switch, which requires careful state transition design. Accessibility testing is explicitly required for the role switch widget, adding QA scope.

Stakeholder review should include a UX walkthrough to validate the single-role no-switch message and focus management behavior.

The role switch widget triggers a coordinated state update across multiple layers. First, the role resolution service must query Supabase to confirm which roles the current user actually holds before rendering switch options—cached role state must not be trusted here. On selection, the role state manager updates the global active role, which should propagate via a reactive state mechanism (context, store, or observable) to all consumers. The role-aware bottom navigation must re-render its tab set based on the new active role, and the home screen must swap to its role-specific variant without a full page reload.

The mid-switch navigation edge case requires the state transition to be atomic or cancellable—no intermediate UI state should persist. All interactive elements in the widget need ARIA labels and correct focus management, which must be verified with automated accessibility tooling as part of the test suite.

Acceptance Criteria

  • Given a user holds both coordinator and peer mentor roles, When they open the role switch widget, Then both roles are listed as selectable options
  • Given a user selects the peer mentor role from the switch widget, When the switch completes, Then the home screen, bottom nav, and all role-gated UI elements update to peer mentor context
  • Given a user holds only one role, When they open the role switch widget, Then no switch option is shown and the widget informs them of their single role
  • Given a role switch is in progress, When the user navigates away, Then the switch completes or rolls back cleanly without leaving the UI in an inconsistent state
  • Given a user with accessibility needs uses the role switch widget, When it renders, Then all interactive elements have proper semantic labels and focus management is correct

Business Value

In smaller chapters, the same volunteer often acts as both peer mentor and coordinator. Requiring them to log out and back in to switch context creates friction that leads to underreporting. Seamless role switching directly addresses the organizations' top priority of minimizing registration effort.