Role-Based Access Control
Feature Detail
Description
The app enforces three primary roles — peer mentor (likeperson), coordinator, and organization admin — each with distinct UI views, navigation options, and data access permissions. Role assignment is managed in Supabase and resolved at login time. Home screen content, contact list views, and available actions all vary by role. Global admins (Norse Digital Products staff) have a no-access screen shown in the mobile app since their administration is performed via a separate admin portal. Role-switching capability exists as a shared widget for users who hold multiple roles.
Analysis
Ensures users only see and access functionality relevant to their responsibilities, reducing cognitive load and preventing accidental data modification. Supports NHF's complex org structure (12 national associations, 9 regions, 1400 local chapters) and HLF's coordinator oversight requirements.
Role resolved from Supabase user metadata or a roles table post-login. Stored in app state (BLoC/Riverpod). StatefulShellRoute and bottom nav tabs rendered conditionally per role. No-access screen for global admin role on mobile. Role switch widget for multi-role users.
Components (204)
Shared Components
These components are reused across multiple features
User Interface (59)
Service Layer (52)
Data Layer (33)
Infrastructure (54)
User Stories (18)
As a As a Peer Mentor (Likeperson)
I want the app to verify my permissions before I execute sensitive actions such as bulk registrations or pause management
So that I am notified immediately if my permissions have changed (e.g., due to an admin action) rather than encountering a cryptic server error mid-flow
- Given a coordinator attempts to initiate a bulk registration, When the permission checker determines their bulk registration permission is active, Then the action proceeds normally
- Given a coordinator's bulk registration permission has been revoked by an admin since login, When the permission checker runs before the action, Then a clear error message is shown explaining the permission issue and no partial action is taken
- Given the permission checker service is unavailable due to a network error, When a coordinator attempts a sensitive action, Then the app displays a retry prompt rather than proceeding without verification
- +1 more
As a 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
- 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
- +2 more
As a As a Peer Mentor (Likeperson)
I want my coordinator permissions to be correctly scoped to the specific chapter or organizational unit I am responsible for
So that I cannot view or modify data belonging to other chapters I do not administer, ensuring data privacy across the organization hierarchy
- Given a coordinator is assigned to Chapter A, When they load the contacts list, Then only contacts associated with Chapter A are returned
- Given a coordinator attempts to access a peer mentor from Chapter B via a direct URL, When the data query executes, Then Supabase RLS policies return no data and the screen shows an appropriate empty state
- Given a coordinator is assigned to multiple chapters, When they select their active chapter context, Then data and actions are scoped to the selected chapter only
- +2 more
As a As a Coordinator
I want the app to verify my permissions before I execute sensitive actions such as bulk registrations or pause management
So that I am notified immediately if my permissions have changed (e.g., due to an admin action) rather than encountering a cryptic server error mid-flow
- Given a coordinator attempts to initiate a bulk registration, When the permission checker determines their bulk registration permission is active, Then the action proceeds normally
- Given a coordinator's bulk registration permission has been revoked by an admin since login, When the permission checker runs before the action, Then a clear error message is shown explaining the permission issue and no partial action is taken
- Given the permission checker service is unavailable due to a network error, When a coordinator attempts a sensitive action, Then the app displays a retry prompt rather than proceeding without verification
- +1 more
As a As a Coordinator
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
- 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
- +2 more
As a As a Coordinator
I want my coordinator permissions to be correctly scoped to the specific chapter or organizational unit I am responsible for
So that I cannot view or modify data belonging to other chapters I do not administer, ensuring data privacy across the organization hierarchy
- Given a coordinator is assigned to Chapter A, When they load the contacts list, Then only contacts associated with Chapter A are returned
- Given a coordinator attempts to access a peer mentor from Chapter B via a direct URL, When the data query executes, Then Supabase RLS policies return no data and the screen shows an appropriate empty state
- Given a coordinator is assigned to multiple chapters, When they select their active chapter context, Then data and actions are scoped to the selected chapter only
- +2 more
As a As a Organization Administrator
I want the app to verify my permissions before I execute sensitive actions such as bulk registrations or pause management
So that I am notified immediately if my permissions have changed (e.g., due to an admin action) rather than encountering a cryptic server error mid-flow
- Given a coordinator attempts to initiate a bulk registration, When the permission checker determines their bulk registration permission is active, Then the action proceeds normally
- Given a coordinator's bulk registration permission has been revoked by an admin since login, When the permission checker runs before the action, Then a clear error message is shown explaining the permission issue and no partial action is taken
- Given the permission checker service is unavailable due to a network error, When a coordinator attempts a sensitive action, Then the app displays a retry prompt rather than proceeding without verification
- +1 more
As a As a Organization Administrator
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
- 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
- +2 more
As a As a Organization Administrator
I want my coordinator permissions to be correctly scoped to the specific chapter or organizational unit I am responsible for
So that I cannot view or modify data belonging to other chapters I do not administer, ensuring data privacy across the organization hierarchy
- Given a coordinator is assigned to Chapter A, When they load the contacts list, Then only contacts associated with Chapter A are returned
- Given a coordinator attempts to access a peer mentor from Chapter B via a direct URL, When the data query executes, Then Supabase RLS policies return no data and the screen shows an appropriate empty state
- Given a coordinator is assigned to multiple chapters, When they select their active chapter context, Then data and actions are scoped to the selected chapter only
- +2 more
As a As a Peer Mentor (Likeperson)
I want to see only the navigation tabs that are relevant to my coordinator role
So that the bottom navigation is uncluttered and I am not distracted by tabs I cannot or should not use
- Given a coordinator is logged in, When the bottom navigation renders, Then exactly the coordinator-permitted tabs are visible and no admin-only tabs appear
- Given a coordinator switches to a peer mentor role using the role switch widget, When the switch completes, Then the bottom navigation updates to show peer mentor tabs
- Given a coordinator is on the Contacts tab and navigates to a contact detail then back, When they return to the tab, Then their scroll position and list state are preserved
- +1 more
As a As a Peer Mentor (Likeperson)
I want to land on a home screen tailored to my coordinator role immediately after logging in
So that I can access my most relevant tools and information without navigating away from an irrelevant default screen
- Given a user with the coordinator role logs in, When role resolution completes, Then the coordinator-specific home screen is displayed without any additional navigation steps
- Given a user has multiple roles, When they switch roles using the role switch widget, Then the home screen updates to reflect the newly selected role
- Given a user's role is revoked between sessions, When they log in again, Then the no-access screen is shown instead of the coordinator home screen
- +1 more
As a As a Peer Mentor (Likeperson)
I want to be prevented from accidentally navigating to screens that belong to other roles
So that I only interact with functionality appropriate for my role, and sensitive peer mentor or admin screens are not inadvertently accessible
- Given a coordinator is authenticated, When they attempt to navigate to a route permitted only for admins, Then they are redirected to the no-access screen
- Given a coordinator is on the no-access screen, When it renders, Then it displays a human-readable explanation and an option to contact support or switch roles
- Given a coordinator navigates to a route they are permitted to access, When the route guard evaluates, Then navigation proceeds without interruption
- +1 more
As a As a Coordinator
I want to see only the navigation tabs that are relevant to my coordinator role
So that the bottom navigation is uncluttered and I am not distracted by tabs I cannot or should not use
- Given a coordinator is logged in, When the bottom navigation renders, Then exactly the coordinator-permitted tabs are visible and no admin-only tabs appear
- Given a coordinator switches to a peer mentor role using the role switch widget, When the switch completes, Then the bottom navigation updates to show peer mentor tabs
- Given a coordinator is on the Contacts tab and navigates to a contact detail then back, When they return to the tab, Then their scroll position and list state are preserved
- +1 more
As a As a Coordinator
I want to land on a home screen tailored to my coordinator role immediately after logging in
So that I can access my most relevant tools and information without navigating away from an irrelevant default screen
- Given a user with the coordinator role logs in, When role resolution completes, Then the coordinator-specific home screen is displayed without any additional navigation steps
- Given a user has multiple roles, When they switch roles using the role switch widget, Then the home screen updates to reflect the newly selected role
- Given a user's role is revoked between sessions, When they log in again, Then the no-access screen is shown instead of the coordinator home screen
- +1 more
As a As a Coordinator
I want to be prevented from accidentally navigating to screens that belong to other roles
So that I only interact with functionality appropriate for my role, and sensitive peer mentor or admin screens are not inadvertently accessible
- Given a coordinator is authenticated, When they attempt to navigate to a route permitted only for admins, Then they are redirected to the no-access screen
- Given a coordinator is on the no-access screen, When it renders, Then it displays a human-readable explanation and an option to contact support or switch roles
- Given a coordinator navigates to a route they are permitted to access, When the route guard evaluates, Then navigation proceeds without interruption
- +1 more
As a As a Organization Administrator
I want to see only the navigation tabs that are relevant to my coordinator role
So that the bottom navigation is uncluttered and I am not distracted by tabs I cannot or should not use
- Given a coordinator is logged in, When the bottom navigation renders, Then exactly the coordinator-permitted tabs are visible and no admin-only tabs appear
- Given a coordinator switches to a peer mentor role using the role switch widget, When the switch completes, Then the bottom navigation updates to show peer mentor tabs
- Given a coordinator is on the Contacts tab and navigates to a contact detail then back, When they return to the tab, Then their scroll position and list state are preserved
- +1 more
As a As a Organization Administrator
I want to land on a home screen tailored to my coordinator role immediately after logging in
So that I can access my most relevant tools and information without navigating away from an irrelevant default screen
- Given a user with the coordinator role logs in, When role resolution completes, Then the coordinator-specific home screen is displayed without any additional navigation steps
- Given a user has multiple roles, When they switch roles using the role switch widget, Then the home screen updates to reflect the newly selected role
- Given a user's role is revoked between sessions, When they log in again, Then the no-access screen is shown instead of the coordinator home screen
- +1 more
As a As a Organization Administrator
I want to be prevented from accidentally navigating to screens that belong to other roles
So that I only interact with functionality appropriate for my role, and sensitive peer mentor or admin screens are not inadvertently accessible
- Given a coordinator is authenticated, When they attempt to navigate to a route permitted only for admins, Then they are redirected to the no-access screen
- Given a coordinator is on the no-access screen, When it renders, Then it displays a human-readable explanation and an option to contact support or switch roles
- Given a coordinator navigates to a route they are permitted to access, When the route guard evaluates, Then navigation proceeds without interruption
- +1 more