prevert directly call of User.hashPassword()

this preverted changes made in 7b8576d. now we use hooks to hash password.
no need to call User.hashPassword() manually.

Signed-off-by: BinotaLIU <me@binota.org>
This commit is contained in:
BinotaLIU 2020-04-14 23:17:16 +08:00
parent 027195e973
commit d4d0120ab7
No known key found for this signature in database
GPG Key ID: 87C590ECC1F5314E
2 changed files with 3 additions and 4 deletions

View File

@ -43,10 +43,9 @@ async function createUser (argv) {
}
const pass = getPass(argv, 'add')
const hashedPass = await models.User.hashPassword(pass)
// Lets try to create, and check success
const ref = await models.User.create({ email: argv['add'], password: hashedPass })
const ref = await models.User.create({ email: argv['add'], password: pass })
if (ref === undefined) {
console.log(`Could not create user with email ${argv['add']}`)
process.exit(1)
@ -80,7 +79,7 @@ async function resetUser (argv) {
const pass = getPass(argv, 'reset')
// set password and save
existingUser.password = await models.User.hashPassword(pass)
existingUser.password = pass
await existingUser.save()
console.log(`User with email ${argv['reset']} password has been reset`)
}

View File

@ -44,7 +44,7 @@ if (config.allowEmailRegister) {
email: req.body.email
},
defaults: {
password: await models.User.hashPassword(req.body.password)
password: req.body.password
}
})