X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=scripts%2Freset-password.ts;h=7c1a64a3f61077b30e3799bc686ee3657ce3f6ff;hb=dfca0f5fc232a1476d4b7296404fb91dbd60b96b;hp=6126c3cd09fa9da04c57b1c52852ad3196627f66;hpb=2aaa1a3fdc49be77aec5309dab5507865c38d392;p=github%2FChocobozzz%2FPeerTube.git diff --git a/scripts/reset-password.ts b/scripts/reset-password.ts index 6126c3cd0..7c1a64a3f 100755 --- a/scripts/reset-password.ts +++ b/scripts/reset-password.ts @@ -2,33 +2,35 @@ import { registerTSPaths } from '../server/helpers/register-ts-paths' registerTSPaths() import * as program from 'commander' -import { initDatabaseModels } from '../server/initializers' -import { UserModel } from '../server/models/account/user' +import { initDatabaseModels } from '../server/initializers/database' +import { UserModel } from '../server/models/user/user' import { isUserPasswordValid } from '../server/helpers/custom-validators/users' program .option('-u, --user [user]', 'User') .parse(process.argv) -if (program['user'] === undefined) { +const options = program.opts() + +if (options.user === undefined) { console.error('All parameters are mandatory.') process.exit(-1) } initDatabaseModels(true) .then(() => { - return UserModel.loadByUsername(program['user']) + return UserModel.loadByUsername(options.user) }) .then(user => { if (!user) { - console.error('User unknown.') + console.error('Unknown user.') process.exit(-1) } const readline = require('readline') const Writable = require('stream').Writable const mutableStdout = new Writable({ - write: function (chunk, encoding, callback) { + write: function (_chunk, _encoding, callback) { callback() } }) @@ -53,3 +55,7 @@ initDatabaseModels(true) .finally(() => process.exit(0)) }) }) + .catch(err => { + console.error(err) + process.exit(-1) + })