Add lamassu-revoke and lamassu-users (#270)
* lamassu-list-users Lists registered users to the admin panel * Add in unregister function to revoke token access * Create lamassu-revoke * Changed name to lamassu-users * Update login.js * Update login.js * Add lamassu-users & lamassu revoke to package.json * Re-add missing comma.
This commit is contained in:
parent
71ed3b83dd
commit
0088ba7068
3 changed files with 32 additions and 1 deletions
20
bin/lamassu-revoke
Normal file
20
bin/lamassu-revoke
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const db = require('../lib/db')
|
||||
|
||||
const argv = process.argv.slice(2)
|
||||
|
||||
if (argv.length !== 1) {
|
||||
console.log('Usage: lamassu-revoke <user>')
|
||||
console.log('Revokes admin panel access from a specific user.')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const name = argv[0]
|
||||
|
||||
const sql = `delete from user_tokens where name = $1 RETURNING *;`
|
||||
|
||||
return db.result(sql, [name], r => r.rowCount)
|
||||
.then(r => {if(r==0){console.log('could not find user.')}
|
||||
else{console.log(name + ' removed successfully.')}})
|
||||
.then(() => process.exit(0))
|
||||
9
bin/lamassu-users
Normal file
9
bin/lamassu-users
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
if [ "$(whoami)" != "root" ]; then
|
||||
echo -e "This script has to be run as \033[1mroot\033[0m user"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
su - postgres -c "psql \"lamassu\" -Atc \"select * from user_tokens\""
|
||||
|
|
@ -87,7 +87,9 @@
|
|||
"lamassu-ofac-update-sources": "./bin/lamassu-ofac-update-sources",
|
||||
"lamassu-devices": "./bin/lamassu-devices",
|
||||
"lamassu-operator": "./bin/lamassu-operator",
|
||||
"lamassu-coinatmradar": "./bin/lamassu-coinatmradar"
|
||||
"lamassu-coinatmradar": "./bin/lamassu-coinatmradar",
|
||||
"lamassu-users": "./bin/lamassu-users",
|
||||
"lamassu-revoke": "./bin/lamassu-revoke"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node bin/lamassu-server",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue