not-node 6.0.2 → 6.0.3
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
CHANGED
|
@@ -22,8 +22,8 @@ module.exports = ({ MODULE_NAME, MODEL_NAME, actionName }) => {
|
|
|
22
22
|
const incField = `${firstLetterToLower(MODEL_NAME)}ID`;
|
|
23
23
|
return {
|
|
24
24
|
targetId: req.params[incField],
|
|
25
|
-
activeUser: req
|
|
26
|
-
activeUserId: req
|
|
25
|
+
activeUser: req?.user,
|
|
26
|
+
activeUserId: req?.user._id,
|
|
27
27
|
ip: getIP(req),
|
|
28
28
|
};
|
|
29
29
|
}
|
package/src/generic/logic.js
CHANGED
|
@@ -72,14 +72,14 @@ module.exports = ({
|
|
|
72
72
|
root
|
|
73
73
|
);
|
|
74
74
|
if (shouldOwn) {
|
|
75
|
-
data[ownerFieldName] = activeUser
|
|
75
|
+
data[ownerFieldName] = activeUser?._id;
|
|
76
76
|
}
|
|
77
77
|
const res = await getModel().add(data);
|
|
78
78
|
LogAction(
|
|
79
79
|
{
|
|
80
80
|
action,
|
|
81
|
-
by: activeUser
|
|
82
|
-
role: activeUser
|
|
81
|
+
by: activeUser?._id,
|
|
82
|
+
role: activeUser?.role,
|
|
83
83
|
ip,
|
|
84
84
|
root,
|
|
85
85
|
},
|
|
@@ -149,14 +149,14 @@ module.exports = ({
|
|
|
149
149
|
_id: targetId,
|
|
150
150
|
};
|
|
151
151
|
if (shouldOwn) {
|
|
152
|
-
query[ownerFieldName] = activeUser
|
|
152
|
+
query[ownerFieldName] = activeUser?._id;
|
|
153
153
|
}
|
|
154
154
|
const result = await getModel().update(query, data);
|
|
155
155
|
LogAction(
|
|
156
156
|
{
|
|
157
157
|
action,
|
|
158
|
-
by: activeUser
|
|
159
|
-
role: activeUser
|
|
158
|
+
by: activeUser?._id,
|
|
159
|
+
role: activeUser?.role,
|
|
160
160
|
ip,
|
|
161
161
|
},
|
|
162
162
|
{
|
|
@@ -243,7 +243,7 @@ module.exports = ({
|
|
|
243
243
|
);
|
|
244
244
|
let query = {};
|
|
245
245
|
if (shouldOwn) {
|
|
246
|
-
query[ownerFieldName] = activeUser
|
|
246
|
+
query[ownerFieldName] = activeUser?._id;
|
|
247
247
|
}
|
|
248
248
|
let populate = getPopulate(action, {
|
|
249
249
|
targetId,
|
|
@@ -255,8 +255,8 @@ module.exports = ({
|
|
|
255
255
|
LogAction(
|
|
256
256
|
{
|
|
257
257
|
action,
|
|
258
|
-
by: activeUser
|
|
259
|
-
role: activeUser
|
|
258
|
+
by: activeUser?._id,
|
|
259
|
+
role: activeUser?.role,
|
|
260
260
|
ip,
|
|
261
261
|
},
|
|
262
262
|
{
|
|
@@ -333,7 +333,7 @@ module.exports = ({
|
|
|
333
333
|
);
|
|
334
334
|
let query = {};
|
|
335
335
|
if (shouldOwn) {
|
|
336
|
-
query[ownerFieldName] = activeUser
|
|
336
|
+
query[ownerFieldName] = activeUser?._id;
|
|
337
337
|
}
|
|
338
338
|
let populate = getPopulate(action, {
|
|
339
339
|
targetID,
|
|
@@ -349,8 +349,8 @@ module.exports = ({
|
|
|
349
349
|
LogAction(
|
|
350
350
|
{
|
|
351
351
|
action,
|
|
352
|
-
by: activeUser
|
|
353
|
-
role: activeUser
|
|
352
|
+
by: activeUser?._id,
|
|
353
|
+
role: activeUser?.role,
|
|
354
354
|
ip,
|
|
355
355
|
},
|
|
356
356
|
{
|
|
@@ -427,14 +427,14 @@ module.exports = ({
|
|
|
427
427
|
);
|
|
428
428
|
let query = {};
|
|
429
429
|
if (shouldOwn) {
|
|
430
|
-
query[ownerFieldName] = activeUser
|
|
430
|
+
query[ownerFieldName] = activeUser?._id;
|
|
431
431
|
}
|
|
432
432
|
const result = await getModel().getOneRaw(targetId, query);
|
|
433
433
|
LogAction(
|
|
434
434
|
{
|
|
435
435
|
action,
|
|
436
|
-
by: activeUser
|
|
437
|
-
role: activeUser
|
|
436
|
+
by: activeUser?._id,
|
|
437
|
+
role: activeUser?.role,
|
|
438
438
|
ip,
|
|
439
439
|
root,
|
|
440
440
|
},
|
|
@@ -516,12 +516,12 @@ module.exports = ({
|
|
|
516
516
|
if (!itm) {
|
|
517
517
|
throw new DBExceptionDocumentIsNotFound();
|
|
518
518
|
}
|
|
519
|
-
if (shouldOwn && !isOwner(itm, activeUser
|
|
519
|
+
if (shouldOwn && !isOwner(itm, activeUser?._id)) {
|
|
520
520
|
throw new DBExceptionDocumentIsNotOwnerByActiveUser({
|
|
521
521
|
params: {
|
|
522
522
|
targetId,
|
|
523
|
-
activeUserId: activeUser
|
|
524
|
-
role: activeUser
|
|
523
|
+
activeUserId: activeUser?._id,
|
|
524
|
+
role: activeUser?.role,
|
|
525
525
|
versioning,
|
|
526
526
|
},
|
|
527
527
|
});
|
|
@@ -531,7 +531,7 @@ module.exports = ({
|
|
|
531
531
|
} else {
|
|
532
532
|
let query = { _id: targetId };
|
|
533
533
|
if (shouldOwn) {
|
|
534
|
-
query[ownerFieldName] = activeUser
|
|
534
|
+
query[ownerFieldName] = activeUser?._id;
|
|
535
535
|
}
|
|
536
536
|
const result = await model.findOneAndDelete(query).exec();
|
|
537
537
|
if (!deleteResponseSuccess(result)) {
|
|
@@ -539,8 +539,8 @@ module.exports = ({
|
|
|
539
539
|
params: {
|
|
540
540
|
result,
|
|
541
541
|
targetId,
|
|
542
|
-
activeUserId: activeUser
|
|
543
|
-
role: activeUser
|
|
542
|
+
activeUserId: activeUser?._id,
|
|
543
|
+
role: activeUser?.role,
|
|
544
544
|
versioning,
|
|
545
545
|
},
|
|
546
546
|
});
|
|
@@ -549,8 +549,8 @@ module.exports = ({
|
|
|
549
549
|
LogAction(
|
|
550
550
|
{
|
|
551
551
|
action,
|
|
552
|
-
by: activeUser
|
|
553
|
-
role: activeUser
|
|
552
|
+
by: activeUser?._id,
|
|
553
|
+
role: activeUser?.role,
|
|
554
554
|
ip,
|
|
555
555
|
root,
|
|
556
556
|
},
|
|
@@ -615,14 +615,14 @@ module.exports = ({
|
|
|
615
615
|
let filter;
|
|
616
616
|
if (shouldOwn) {
|
|
617
617
|
filter = {
|
|
618
|
-
[ownerFieldName]: activeUser
|
|
618
|
+
[ownerFieldName]: activeUser?._id,
|
|
619
619
|
};
|
|
620
620
|
}
|
|
621
621
|
const result = await getModel().listAll(filter);
|
|
622
622
|
LogAction({
|
|
623
623
|
action,
|
|
624
|
-
by: activeUser
|
|
625
|
-
role: activeUser
|
|
624
|
+
by: activeUser?._id,
|
|
625
|
+
role: activeUser?.role,
|
|
626
626
|
ip,
|
|
627
627
|
root,
|
|
628
628
|
shouldOwn,
|
|
@@ -670,7 +670,7 @@ module.exports = ({
|
|
|
670
670
|
});
|
|
671
671
|
if (shouldOwn) {
|
|
672
672
|
notFilter.filter.modifyRules(filter, {
|
|
673
|
-
[ownerFieldName]: activeUser
|
|
673
|
+
[ownerFieldName]: activeUser?._id,
|
|
674
674
|
});
|
|
675
675
|
}
|
|
676
676
|
const result = await getModel().listAndCount(
|
|
@@ -683,8 +683,8 @@ module.exports = ({
|
|
|
683
683
|
);
|
|
684
684
|
LogAction({
|
|
685
685
|
action,
|
|
686
|
-
by: activeUser
|
|
687
|
-
role: activeUser
|
|
686
|
+
by: activeUser?._id,
|
|
687
|
+
role: activeUser?.role,
|
|
688
688
|
ip,
|
|
689
689
|
root,
|
|
690
690
|
shouldOwn,
|
|
@@ -734,7 +734,7 @@ module.exports = ({
|
|
|
734
734
|
});
|
|
735
735
|
if (shouldOwn) {
|
|
736
736
|
notFilter.filter.modifyRules(filter, {
|
|
737
|
-
[ownerFieldName]: activeUser
|
|
737
|
+
[ownerFieldName]: activeUser?._id,
|
|
738
738
|
});
|
|
739
739
|
}
|
|
740
740
|
const result = await getModel().listAndPopulate(
|
|
@@ -746,8 +746,8 @@ module.exports = ({
|
|
|
746
746
|
);
|
|
747
747
|
LogAction({
|
|
748
748
|
action,
|
|
749
|
-
by: activeUser
|
|
750
|
-
role: activeUser
|
|
749
|
+
by: activeUser?._id,
|
|
750
|
+
role: activeUser?.role,
|
|
751
751
|
ip,
|
|
752
752
|
root,
|
|
753
753
|
shouldOwn,
|
|
@@ -793,7 +793,7 @@ module.exports = ({
|
|
|
793
793
|
const { filter, search } = query;
|
|
794
794
|
if (shouldOwn) {
|
|
795
795
|
notFilter.filter.modifyRules(filter, {
|
|
796
|
-
[ownerFieldName]: activeUser
|
|
796
|
+
[ownerFieldName]: activeUser?._id,
|
|
797
797
|
});
|
|
798
798
|
}
|
|
799
799
|
if (search) {
|
|
@@ -802,8 +802,8 @@ module.exports = ({
|
|
|
802
802
|
const result = await getModel().countWithFilter(search || filter);
|
|
803
803
|
LogAction({
|
|
804
804
|
action,
|
|
805
|
-
by: activeUser
|
|
806
|
-
role: activeUser
|
|
805
|
+
by: activeUser?._id,
|
|
806
|
+
role: activeUser?.role,
|
|
807
807
|
ip,
|
|
808
808
|
root,
|
|
809
809
|
shouldOwn,
|