I implemented email confirmation feature in my fork but before I create new PR I have question.
userSchema.method({
transform () {
const transformed = {}
const fields = ['id', 'name', 'email', 'createdAt', 'activationKey', 'role']
fields.forEach((field) => {
transformed[field] = this[field]
})
return transformed
},
passwordMatches (password) {
return bcrypt.compareSync(password, this.password)
}
})
if (!this.isModified('activationKey')) {
console.log('Not modified.. but what does it mean?')
return next()
}
if (!user.active) throw new APIError(`User not activated`, httpStatus.UNAUTHORIZED)