usersWithRole method

  1. @override
Future<List<String>> usersWithRole(
  1. String roleId
)
override

Returns the IDs of all users that have roleId assigned.

Implementation

@override
Future<List<String>> usersWithRole(String roleId) async {
  try {
    final query =
        await _firestore
            .collection(_usersCollection)
            .where(_rolesField, arrayContains: roleId)
            .get();

    return query.docs.map((d) => d.id).toList(growable: false);
  } catch (error) {
    throw Exception(
      'FirebaseRbacProvider.usersWithRole failed for role "$roleId": $error',
    );
  }
}