Error on invalid password in reset password script

pull/1830/head
Chocobozzz 2019-02-14 09:44:33 +01:00
parent f5305c04aa
commit e1fa026675
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 6 additions and 0 deletions

View File

@ -1,6 +1,7 @@
import * as program from 'commander'
import { initDatabaseModels } from '../server/initializers'
import { UserModel } from '../server/models/account/user'
import { isUserPasswordValid } from '../server/helpers/custom-validators/users'
program
.option('-u, --user [user]', 'User')
@ -36,6 +37,11 @@ initDatabaseModels(true)
console.log('New password?')
rl.on('line', function (password) {
if (!isUserPasswordValid(password)) {
console.error('New password is invalid.')
process.exit(-1)
}
user.password = password
user.save()