diff --git a/server/models/user/user.ts b/server/models/user/user.ts index c1e7abea6..b974418d4 100644 --- a/server/models/user/user.ts +++ b/server/models/user/user.ts @@ -136,10 +136,13 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da } function beforeCreateOrUpdate (user: UserInstance) { - return cryptPassword(user.password).then(hash => { - user.password = hash - return undefined - }) + if (user.changed('password')) { + return cryptPassword(user.password) + .then(hash => { + user.password = hash + return undefined + }) + } } // ------------------------------ METHODS ------------------------------