This commit is contained in:
2019-07-10 23:45:46 -04:00
parent ebda307995
commit d5b34dc81f
3 changed files with 29 additions and 5 deletions

View File

@@ -66,8 +66,8 @@ const UserSchema = new mongoose.Schema(
trim: true,
},
address: [ AddressSchema ],
phone: [ PhoneSchema ],
addresses: [ AddressSchema ],
phones: [ PhoneSchema ],
credentials: [ LoginSchema ],
tokenCheckBit: {
@@ -256,6 +256,27 @@ UserSchema.methods.toAuthJSON = function () {
};
};
UserSchema.methods.toProfileJSON = function () {
const hasNomDeBid = !!this.nomDeBid;
const nomDeBid = this.getNomDeBid();
return {
addresses: this.addresses,
avatar: this.avatar,
email: this.email,
firstName: this.firstName,
generatedNomDeBid: !hasNomDeBid,
isAllowedToBid: this.isAllowedToBid,
isOrganizationEmployee: this.isOrganizationEmployee,
isVerified: this.isVerified,
lastName: this.lastName,
nomDeBid: nomDeBid,
organizationIdentifier: this.organizationIdentifier,
paymentToken: this.paymentToken,
phones: this.phones,
};
};
UserSchema.methods.validatePassword = function (password) {
const strategy = this.getAuthStrategy('local');