diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-04 18:09:23 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-04 18:09:23 +0100 |
commit | 59557c4663814b05fb3b2209c486c73a432a65b5 (patch) | |
tree | bc9a50b0b5247b221ec214ea4f292baa0f79bbfb /server/models/user/user.ts | |
parent | 08535e56aa4495adc62702897b241768c6d12f40 (diff) | |
download | PeerTube-59557c4663814b05fb3b2209c486c73a432a65b5.tar.gz PeerTube-59557c4663814b05fb3b2209c486c73a432a65b5.tar.zst PeerTube-59557c4663814b05fb3b2209c486c73a432a65b5.zip |
Don't hash user password once again on update
Diffstat (limited to 'server/models/user/user.ts')
-rw-r--r-- | server/models/user/user.ts | 11 |
1 files changed, 7 insertions, 4 deletions
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 | |||
136 | } | 136 | } |
137 | 137 | ||
138 | function beforeCreateOrUpdate (user: UserInstance) { | 138 | function beforeCreateOrUpdate (user: UserInstance) { |
139 | return cryptPassword(user.password).then(hash => { | 139 | if (user.changed('password')) { |
140 | user.password = hash | 140 | return cryptPassword(user.password) |
141 | return undefined | 141 | .then(hash => { |
142 | }) | 142 | user.password = hash |
143 | return undefined | ||
144 | }) | ||
145 | } | ||
143 | } | 146 | } |
144 | 147 | ||
145 | // ------------------------------ METHODS ------------------------------ | 148 | // ------------------------------ METHODS ------------------------------ |