aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/user
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-04 18:09:23 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-04 18:09:23 +0100
commit59557c4663814b05fb3b2209c486c73a432a65b5 (patch)
treebc9a50b0b5247b221ec214ea4f292baa0f79bbfb /server/models/user
parent08535e56aa4495adc62702897b241768c6d12f40 (diff)
downloadPeerTube-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')
-rw-r--r--server/models/user/user.ts11
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
138function beforeCreateOrUpdate (user: UserInstance) { 138function 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 ------------------------------