not-node 5.1.16 → 5.1.19
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.
- package/package.json +1 -1
- package/src/auth/fields.js +0 -1
- package/src/exceptions/db.js +7 -0
- package/src/generic/logic.js +8 -2
package/package.json
CHANGED
package/src/auth/fields.js
CHANGED
package/src/exceptions/db.js
CHANGED
|
@@ -21,3 +21,10 @@ class DBExceptionDocumentIsNotOwnerByActiveUser extends notRequestError {
|
|
|
21
21
|
}
|
|
22
22
|
module.exports.DBExceptionDocumentIsNotOwnerByActiveUser =
|
|
23
23
|
DBExceptionDocumentIsNotOwnerByActiveUser;
|
|
24
|
+
|
|
25
|
+
class DBExceptionDocumentIsNotFound extends notRequestError {
|
|
26
|
+
constructor({ params = {}, cause = null } = {}) {
|
|
27
|
+
super("DB document is not found", { code: 404, ...params }, cause);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
module.exports.DBExceptionDocumentIsNotFound = DBExceptionDocumentIsNotFound;
|
package/src/generic/logic.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
const { objHas, isFunc, executeFunctionAsAsync } = require("../common");
|
|
2
2
|
const ModelRoutine = require("../model/routine");
|
|
3
3
|
const { deleteResponseSuccess } = require("../model/utils.js");
|
|
4
|
-
const {
|
|
4
|
+
const {
|
|
5
|
+
DBExceptionDocumentIsNotFound,
|
|
6
|
+
DBExceptionDeleteWasNotSuccessful,
|
|
7
|
+
} = require("../exceptions/db.js");
|
|
5
8
|
const {
|
|
6
9
|
DBExceptionDocumentIsNotOwnerByActiveUser,
|
|
7
10
|
} = require("../exceptions/http");
|
|
@@ -416,7 +419,10 @@ module.exports = ({
|
|
|
416
419
|
const versioning = ModelRoutine.versioning(model);
|
|
417
420
|
if (versioning) {
|
|
418
421
|
let itm = await model.getOneRaw(targetId);
|
|
419
|
-
if (
|
|
422
|
+
if (!itm) {
|
|
423
|
+
throw new DBExceptionDocumentIsNotFound();
|
|
424
|
+
}
|
|
425
|
+
if (shouldOwn && !isOwner(itm, activeUser._id)) {
|
|
420
426
|
throw new DBExceptionDocumentIsNotOwnerByActiveUser({
|
|
421
427
|
params: {
|
|
422
428
|
targetId,
|