Skip to content

Commit 02fc87e

Browse files
committed
feat(push_notification_device): implement read operation and update permissions
- Add read operation for push_notification_device in DataOperationRegistry - Update getCollectionPermission to unsupported for better security - Change getItemPermission to adminOnly to restrict unauthorized access
1 parent abe6bb7 commit 02fc87e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/src/registry/data_operation_registry.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ class DataOperationRegistry {
125125
'in_app_notification': (c, id) => c
126126
.read<DataRepository<InAppNotification>>()
127127
.read(id: id, userId: null),
128+
'push_notification_device': (c, id) => c
129+
.read<DataRepository<PushNotificationDevice>>()
130+
.read(id: id, userId: null),
128131
});
129132

130133
// --- Register "Read All" Readers ---

lib/src/registry/model_registry.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,14 +429,12 @@ final modelRegistry = <String, ModelConfig<dynamic>>{
429429
fromJson: PushNotificationDevice.fromJson,
430430
getId: (d) => d.id,
431431
getOwnerId: (dynamic item) => (item as PushNotificationDevice).userId,
432-
// Required by the ownership check middelware used by the deletePermission.
433432
getCollectionPermission: const ModelActionPermission(
434-
type: RequiredPermissionType.adminOnly,
433+
type: RequiredPermissionType.unsupported,
435434
),
436-
// Item GET is not supported for this model. A client registers a device
437-
// and then forgets about it until it needs to be deleted.
435+
// Required by the ownership check middelware
438436
getItemPermission: const ModelActionPermission(
439-
type: RequiredPermissionType.unsupported,
437+
type: RequiredPermissionType.adminOnly,
440438
),
441439
// POST is allowed for any authenticated user to register their own device.
442440
// A custom check within the DataOperationRegistry's creator function will

0 commit comments

Comments
 (0)