mirror of
https://github.com/Retropex/apolloapi-v2.git
synced 2025-06-03 07:52:29 +02:00
18 lines
508 B
JavaScript
18 lines
508 B
JavaScript
module.exports = ({ define }) => {
|
|
define('changePassword', async ({ password }, { knex, errors, utils }) => {
|
|
// TODO transaction
|
|
const [ setup ] = await knex('setup').select('*').limit(1)
|
|
if (!setup) {
|
|
throw new errors.AuthorizationError('Setup not finished')
|
|
}
|
|
await knex('setup').update({
|
|
password: await utils.auth.hashPassword(password)
|
|
})
|
|
|
|
utils.auth.changeSystemPassword(password)
|
|
utils.auth.changeNodeRpcPassword(password)
|
|
}, {
|
|
auth: true
|
|
})
|
|
}
|