@snowtop/ent 0.1.0-alpha144 → 0.1.0-alpha145
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/core/ent.js +4 -3
- package/package.json +1 -1
package/core/ent.js
CHANGED
|
@@ -509,11 +509,12 @@ async function doFieldPrivacy(viewer, ent, data, options) {
|
|
|
509
509
|
}
|
|
510
510
|
const promises = [];
|
|
511
511
|
let somethingChanged = false;
|
|
512
|
+
const clone = { ...data };
|
|
512
513
|
const origData = {
|
|
513
514
|
...data,
|
|
514
515
|
};
|
|
515
516
|
for (const [k, policy] of options.fieldPrivacy) {
|
|
516
|
-
const curr =
|
|
517
|
+
const curr = clone[k];
|
|
517
518
|
if (curr === null || curr === undefined) {
|
|
518
519
|
continue;
|
|
519
520
|
}
|
|
@@ -521,7 +522,7 @@ async function doFieldPrivacy(viewer, ent, data, options) {
|
|
|
521
522
|
// don't do anything if key is null or for some reason missing
|
|
522
523
|
const r = await (0, privacy_1.applyPrivacyPolicy)(viewer, policy, ent);
|
|
523
524
|
if (!r) {
|
|
524
|
-
|
|
525
|
+
clone[k] = null;
|
|
525
526
|
somethingChanged = true;
|
|
526
527
|
}
|
|
527
528
|
})());
|
|
@@ -529,7 +530,7 @@ async function doFieldPrivacy(viewer, ent, data, options) {
|
|
|
529
530
|
await Promise.all(promises);
|
|
530
531
|
if (somethingChanged) {
|
|
531
532
|
// have to create new instance
|
|
532
|
-
const ent = new options.ent(viewer,
|
|
533
|
+
const ent = new options.ent(viewer, clone);
|
|
533
534
|
ent.__setRawDBData(origData);
|
|
534
535
|
return ent;
|
|
535
536
|
}
|