hasAnyRole method

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

Check if token holder has any of the specified roles

Implementation

Future<bool> hasAnyRole(
  String token,
  List<String> roles, {
  String? resource,
  Map<String, dynamic>? context,
}) async {
  try {
    final contextObj = await authorize(
      token,
      resource: resource,
      context: context,
    );
    return contextObj.hasAnyRole(roles);
  } on Exception {
    return false;
  }
}