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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user