grantRoles method

  1. @override
Future<List<String>> grantRoles(
  1. String? correlationId,
  2. String? userId,
  3. List<String> roles
)
override

Grants a roles.

  • correlation_id (optional) transaction id to trace execution through call chain.
  • userId an user id.
  • roles a roles to be granted. Return (optional) Future that receives granted roles or error.

Implementation

@override
Future<List<String>> grantRoles(
    String? correlationId, String? userId, List<String> roles) async {
  if (roles.isEmpty) {
    return [];
  }
  var existingRoles = await getRolesById(correlationId, userId);
  var newRoles = roles;

  if (existingRoles != null) newRoles.addAll(existingRoles);

  return setRoles(correlationId, userId, newRoles.toSet().toList());
}