We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d99346f commit 027195eCopy full SHA for 027195e
lib/models/user.js
@@ -57,6 +57,18 @@ module.exports = function (sequelize, DataTypes) {
57
return false
58
}
59
60
+ User.addHook('beforeCreate', async function (user) {
61
+ // only do hash when password is presented
62
+ if (user.password) {
63
+ user.password = await User.hashPassword(user.password)
64
+ }
65
+ })
66
+ User.addHook('beforeUpdate', async function (user) {
67
+ if (user.changed('password')) {
68
69
70
71
+
72
User.associate = function (models) {
73
User.hasMany(models.Note, {
74
foreignKey: 'ownerId',
0 commit comments