Change password for a given user. Usage:
Note that this can also be achieved on the web interface by visiting the settings page of a target user with an OurBigBook Admin account.
set-password <username> <new-password>
web/bin/set-password
#!/usr/bin/env node
// https://docs.ourbigbook.com/web/bin/set-password
const path = require('path')
const commander = require('commander')
const models = require('../models')
// CLI arguments
const program = commander.program
program.allowExcessArguments(false)
program.argument('<username>', 'username')
program.argument('<password>', 'password')
program.parse(process.argv);
const opts = program.opts()
const [username, password] = program.processedArgs
// main
const sequelize = models.getSequelize(path.dirname(__dirname));
(async () => {
const user = await sequelize.models.User.findOne({ where: { username }})
await sequelize.models.User.setPassword(user, password)
await user.save()
})().finally(() => { return sequelize.close() });