Service Layer medium complexity mobile
1
Dependencies
1
Dependents
3
Entities
0
Integrations

Description

Business logic service managing the full profile-switching lifecycle. Queries the user_roles table to enumerate available roles and org/local-association combinations for the current user, updates the active role context in secure state, invalidates role-dependent Riverpod/BLoC providers, and navigates to the correct home screen variant. Ensures all subsequent data queries (activities, statistics, assignments) are scoped to the newly active org context to prevent cross-tenant data leakage.

Feature: Profile Switching

profile-switch-service

Responsibilities

  • Fetch all user_roles records for the authenticated user including org and local_association context
  • Persist the selected role context via Active Role State Repository
  • Invalidate and re-initialize role-dependent Riverpod providers or BLoC instances on switch
  • Navigate to the role-specific home screen (Peer Mentor Home or Coordinator Home) after a switch
  • Expose the active role context so that activity, statistics, and assignment queries are always correctly scoped

Interfaces

getAvailableRoles(String userId) → Future<List<UserRoleContext>>
switchActiveRole(UserRoleContext roleContext) → Future<void>
getActiveRoleContext() → UserRoleContext?
invalidateRoleDependentProviders() → void

Relationships

Dependencies (1)

Components this component depends on

Dependents (1)

Components that depend on this component

Related Data Entities (3)

Data entities managed by this component