Skip to content

Commit

Permalink
fix(cli): Added command 'export' to retrieve raw account data with cr…
Browse files Browse the repository at this point in the history
…edentials
  • Loading branch information
andris9 committed Jul 21, 2024
1 parent f00f864 commit 9932801
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
26 changes: 26 additions & 0 deletions bin/emailengine.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const settings = require('../lib/settings');
const { checkLicense } = require('../lib/tools');
const pbkdf2 = require('@phc/pbkdf2');
const { PDKDF2_ITERATIONS, PDKDF2_SALT_SIZE, PDKDF2_DIGEST, generateWebhookTable } = require('../lib/consts');
const { Account } = require('../lib/account');
const getSecret = require('../lib/get-secret');
const { redis } = require('../lib/db');

const argv = require('minimist')(process.argv.slice(2));
const msgpack = require('msgpack5')();
Expand Down Expand Up @@ -264,6 +267,29 @@ function run() {
process.exit(1);
break;

case 'export':
{
getSecret()
.then(secret => {
let account = (argv.account || argv.a || '').toString();
let accountObject = new Account({
redis,
account,
secret
});
return accountObject.loadAccountData(account, false);
})
.then(accountData => {
process.stdout.write(JSON.stringify(accountData));
process.exit(0);
})
.catch(err => {
console.error(err);
process.exit(1);
});
}
break;

default:
// run normally
require('../server');
Expand Down
5 changes: 5 additions & 0 deletions help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ Token management commands
emailengine tokens import Imports token data
--token, -t Exported token [string]

Account management commands

emailengine export Exports raw account data including credentials
--account, -a Account indentifier [string]

Password management commands
emailengine password Set admin password
--password, -p Password to use. Autogenerated if not set. [string]
Expand Down

0 comments on commit 9932801

Please sign in to comment.