@stonyx/orm 0.3.2-alpha.116 → 0.3.2-alpha.117

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +4 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -821,8 +821,10 @@ beforeHook('delete', 'animal', (context) => {
821
821
  const user = context.state.currentUser;
822
822
  const animal = store.get('animal', context.request.recordId);
823
823
 
824
- // `animal.owner` is the related Record, so compare its id
825
- if (animal.owner?.id !== user.id && !user.isAdmin) {
824
+ // `animal.owner` is the related Record, so compare its id. Refuse an unowned
825
+ // animal outright: `animal.owner?.id !== user.id` lets a user with no id
826
+ // delete it, because `undefined !== undefined` is false
827
+ if (!user.isAdmin && (!animal.owner || animal.owner.id !== user.id)) {
826
828
  return 403; // Forbidden
827
829
  }
828
830
  });
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "stonyx-async",
5
5
  "stonyx-module"
6
6
  ],
7
- "version": "0.3.2-alpha.116",
7
+ "version": "0.3.2-alpha.117",
8
8
  "description": "",
9
9
  "main": "dist/index.js",
10
10
  "type": "module",