hasRole method

bool hasRole(
  1. String role
)

Checks if the user has a specific role.

Implementation

bool hasRole(String role) {
  // First check the map representation
  final user = this.user;
  if (user != null) {
    final roles = user['roles'];
    if (roles is List<dynamic>) {
      return roles.contains(role);
    }
  }

  // If no map data, check if we have an Authenticatable instance
  // Note: The Authenticatable interface doesn't define roles,
  // so this would need to be implemented by subclasses
  return false;
}