Use UserRole enum for session role handling

Replace string-based role handling with a typed UserRole enum. Adds src/entities/enums/user_role.dart and exports it from krow_domain. Update SessionHandlerMixin to use List<UserRole> and change fetchUserRole to return UserRole?. V2SessionService now derives the role via UserRole.fromSessionData, and client/staff SessionListener widgets pass const <UserRole>[...] when initializing the auth listener. This centralizes role derivation and eliminates scattered role string literals.
This commit is contained in:
Achintha Isuru
2026-03-17 11:19:54 -04:00
parent cc4e2664b6
commit eccd2c6dbd
6 changed files with 44 additions and 24 deletions

View File

@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:krow_core/core.dart';
import 'package:krow_domain/krow_domain.dart' show UserRole;
/// A widget that listens to session state changes and handles global reactions.
///
@@ -37,7 +38,7 @@ class _SessionListenerState extends State<SessionListener> {
final V2SessionService sessionService = Modular.get<V2SessionService>();
sessionService.initializeAuthListener(
allowedRoles: const <String>['CLIENT', 'BUSINESS', 'BOTH'],
allowedRoles: const <UserRole>[UserRole.business, UserRole.both],
);
_sessionSubscription = sessionService.onSessionStateChanged

View File

@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:krow_core/core.dart';
import 'package:krow_domain/krow_domain.dart' show UserRole;
/// A widget that listens to session state changes and handles global reactions.
///
@@ -37,7 +38,7 @@ class _SessionListenerState extends State<SessionListener> {
final V2SessionService sessionService = Modular.get<V2SessionService>();
sessionService.initializeAuthListener(
allowedRoles: const <String>['STAFF', 'BOTH'],
allowedRoles: const <UserRole>[UserRole.staff, UserRole.both],
);
_sessionSubscription = sessionService.onSessionStateChanged