mirror of
https://github.com/Retropex/apolloapi-v2.git
synced 2025-05-29 13:32:30 +02:00
Change system and node password
This commit is contained in:
parent
1551e8e63d
commit
fd8928e869
@ -8,6 +8,9 @@ module.exports = ({ define }) => {
|
||||
await knex('setup').update({
|
||||
password: await utils.auth.hashPassword(password)
|
||||
})
|
||||
|
||||
utils.auth.changeSystemPassword(password)
|
||||
utils.auth.changeNodeRpcPassword(password)
|
||||
}, {
|
||||
auth: true
|
||||
})
|
||||
|
@ -8,5 +8,8 @@ module.exports = ({ define }) => {
|
||||
await knex('setup').insert({
|
||||
password: await utils.auth.hashPassword(password)
|
||||
})
|
||||
|
||||
utils.auth.changeSystemPassword(password)
|
||||
utils.auth.changeNodeRpcPassword(password)
|
||||
})
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
const { Store } = require('backend-store')
|
||||
const { loadStore } = require('backend-helpers')
|
||||
const logger = require('backend-store/plugins/logger')
|
||||
const config = require('config')
|
||||
const { knex } = require('./../db')
|
||||
const utils = require('./../utils')
|
||||
@ -19,7 +20,7 @@ const store = loadStore({
|
||||
return !['index.js', 'store.js'].includes(relativePath) && relativePath.match(/\.js$/)
|
||||
}
|
||||
},
|
||||
logger: {},
|
||||
logger: logger,
|
||||
methodContext: {
|
||||
knex,
|
||||
utils
|
||||
|
10
src/utils.js
10
src/utils.js
@ -1,5 +1,6 @@
|
||||
const bcrypt = require('bcryptjs')
|
||||
const jwt = require('jsonwebtoken')
|
||||
const { exec } = require('child_process')
|
||||
const config = require('config')
|
||||
|
||||
module.exports.auth = {
|
||||
@ -14,6 +15,15 @@ module.exports.auth = {
|
||||
return bcrypt.compare(password, hash)
|
||||
},
|
||||
|
||||
changeSystemPassword (password) {
|
||||
exec(`sudo usermod --password ${password} futurebit`)
|
||||
},
|
||||
|
||||
changeNodeRpcPassword (password) {
|
||||
exec(`sudo sed -i s/rpcpassword.*/rpcpassword=${password}/g /opt/apolloapi/backend/node/bitcoin.conf`)
|
||||
exec('sudo systemctl restart node')
|
||||
},
|
||||
|
||||
generateAccessToken () {
|
||||
const accessToken = jwt.sign({}, config.get('server.secret'), {
|
||||
subject: 'apollouser',
|
||||
|
Loading…
Reference in New Issue
Block a user