checkRoles method

Future<Map<String, bool>> checkRoles(
  1. String token,
  2. List<String> roles, {
  3. String? resource,
  4. Map<String, dynamic>? context,
})

Batch check multiple roles

Implementation

Future<Map<String, bool>> checkRoles(
  String token,
  List<String> roles, {
  String? resource,
  Map<String, dynamic>? context,
}) async {
  try {
    final authMetadata = await _authValidator.validateToken(token);
    return await _authzProvider.checkRoles(
      authMetadata.userId,
      roles,
      resource: resource,
      context: context,
    );
  } on Exception {
    return Map.fromEntries(roles.map((role) => MapEntry(role, false)));
  }
}