hasRole method

Future<bool> hasRole(
  1. RoleType role
)

Returns true when the user currently has the given role.

Example:

if (await user.hasRole(RoleType.admin)) {
  print('User can access admin routes');
}

Implementation

Future<bool> hasRole(RoleType role) async {
  return (await roles).any((userRole) => userRole.name == role.name);
}