PermissionHandlerService.create constructor
PermissionHandlerService.create({
- bool defaultPermission = true,
- Map<
DbOperationType, bool> ? defaultRules, - List<
DbCollection> ? collections,
Implementation
PermissionHandlerService.create(
{bool defaultPermission = true,
Map<DbOperationType, bool>? defaultRules,
List<DbCollection>? collections})
: _defaultRules = defaultRules ??
DbOperationType.values
.asMap()
.map((key, value) => MapEntry(value, defaultPermission)),
_collections = HashMap.from(collections
?.where((element) => element.permissionHandler != null)
.toList()
.asMap()
.map((key, value) =>
MapEntry(value.collectionName, value.permissionHandler)) ??
{}) {
for (var r in DbOperationType.values) {
_defaultRules[r] ??= defaultPermission;
}
}