@lyxa.ai/core 1.2.84 → 1.2.86
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.
|
@@ -54,10 +54,15 @@ exports.CoreEmailAuthIdentity = CoreEmailAuthIdentity = __decorate([
|
|
|
54
54
|
}),
|
|
55
55
|
(0, typegoose_1.pre)('findOneAndUpdate', async function (next) {
|
|
56
56
|
const update = this.getUpdate();
|
|
57
|
+
if (!update)
|
|
58
|
+
return next();
|
|
57
59
|
if (update?.password) {
|
|
58
60
|
update.password = await hashPassword(update.password);
|
|
59
|
-
this.setUpdate(update);
|
|
60
61
|
}
|
|
62
|
+
if (update.$set?.password) {
|
|
63
|
+
update.$set.password = await hashPassword(update.$set.password);
|
|
64
|
+
}
|
|
65
|
+
this.setUpdate(update);
|
|
61
66
|
next();
|
|
62
67
|
})
|
|
63
68
|
], CoreEmailAuthIdentity);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-email-auth-identity.model.js","sourceRoot":"/","sources":["libraries/mongo/models/providers/core-email-auth-identity.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAoE;AACpE,0EAA+D;AAC/D,mEAAyD;AACzD,wDAA8B;AAE9B,yEAAsE;AAEtE,KAAK,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,IAAI,GAAG,MAAM,kBAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtC,OAAO,kBAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACpC,CAAC;
|
|
1
|
+
{"version":3,"file":"core-email-auth-identity.model.js","sourceRoot":"/","sources":["libraries/mongo/models/providers/core-email-auth-identity.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAoE;AACpE,0EAA+D;AAC/D,mEAAyD;AACzD,wDAA8B;AAE9B,yEAAsE;AAEtE,KAAK,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,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vD,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,CAAC,QAAQ,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjE,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACvB,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,qBAAqB,CAYjC","sourcesContent":["import { modelOptions, prop, pre, Ref } from '@typegoose/typegoose';\nimport { CoreAuthIdentity } from '../core-auth-identity.model';\nimport { OTPFields } from '../embedded/otp-fields.model';\nimport bcrypt from 'bcryptjs';\nimport { Query } from 'mongoose';\nimport { ResetPasswordFields } from '../embedded/rest-password.model';\n\nasync function hashPassword(password: string): Promise<string> {\n\tconst salt = await bcrypt.genSalt(10);\n\treturn bcrypt.hash(password, salt);\n}\n@pre<CoreEmailAuthIdentity>('save', async function (next) {\n\tif (this.isModified('password')) {\n\t\tthis.password = await hashPassword(this.password);\n\t}\n\tnext();\n})\n@pre<Query<any, CoreEmailAuthIdentity>>('findOneAndUpdate', async function (next) {\n\tconst update = this.getUpdate() as Record<string, any>;\n\tif (!update) return next();\n\n\tif (update?.password) {\n\t\tupdate.password = await hashPassword(update.password);\n\t}\n\n\tif (update.$set?.password) {\n\t\tupdate.$set.password = await hashPassword(update.$set.password);\n\t}\n\n\tthis.setUpdate(update);\n\tnext();\n})\nexport class CoreEmailAuthIdentity extends CoreAuthIdentity {\n\t@prop({ required: true, type: String })\n\tpublic email!: string;\n\n\t@prop({ required: true, type: String })\n\tpublic password!: string;\n\n\t@prop({ type: OTPFields })\n\tpublic otps?: OTPFields[];\n\n\t@prop({ _id: false })\n\tpublic resetPassword?: ResetPasswordFields;\n}\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED