@jcbuisson/express-x 2.1.18 → 2.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/index.mjs +8 -6
package/package.json
CHANGED
package/src/index.mjs
CHANGED
|
@@ -329,14 +329,16 @@ export const hashPassword = (passwordField) => async (context) => {
|
|
|
329
329
|
*/
|
|
330
330
|
export function protect(field) {
|
|
331
331
|
return async (context) => {
|
|
332
|
-
if (
|
|
333
|
-
|
|
334
|
-
|
|
332
|
+
if (context.result) {
|
|
333
|
+
if (Array.isArray(context.result)) {
|
|
334
|
+
for (const value of context.result) {
|
|
335
|
+
delete value[field]
|
|
336
|
+
}
|
|
337
|
+
} else if (typeof context.result === "object") {
|
|
338
|
+
delete context.result[field]
|
|
335
339
|
}
|
|
336
|
-
} else {
|
|
337
|
-
delete context.result[field]
|
|
338
340
|
}
|
|
339
|
-
return
|
|
341
|
+
return context
|
|
340
342
|
}
|
|
341
343
|
}
|
|
342
344
|
|