hasRole method

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

Check if token holder has specific role

Implementation

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