Skip to content

Commit

Permalink
Encrypt falsy values, except undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
donwojtallo authored and wheresvic committed Jan 28, 2022
1 parent 44cfc01 commit 930e0e2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mongoose-field-encryption.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const fieldEncryption = function (schema, options) {
const encryptedFieldData = encryptedFieldName + encryptedFieldDataSuffix;
const fieldValue = obj[field];

if (!obj[encryptedFieldName] && fieldValue) {
if (!obj[encryptedFieldName] && typeof fieldValue !== "undefined") {
if (typeof fieldValue === "string") {
// handle strings separately to maintain searchability
const value = encryptionStrategy(fieldValue, secret, saltGenerator);
Expand Down

0 comments on commit 930e0e2

Please sign in to comment.