mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-09 09:51:02 +01:00
prompt for unlock if can interact
This commit is contained in:
parent
268852035a
commit
e7450d27e4
2
jslib
2
jslib
@ -1 +1 @@
|
|||||||
Subproject commit 8ab36db5c6d07724326853207690338a27589f43
|
Subproject commit 57e49207e9ad57c71576fc487a38513a4d0fe120
|
@ -15,7 +15,8 @@ export class ExportCommand {
|
|||||||
constructor(private cryptoService: CryptoService, private exportService: ExportService) { }
|
constructor(private cryptoService: CryptoService, private exportService: ExportService) { }
|
||||||
|
|
||||||
async run(password: string, cmd: program.Command): Promise<Response> {
|
async run(password: string, cmd: program.Command): Promise<Response> {
|
||||||
if (password == null || password === '') {
|
const canInteract = process.stdout.isTTY && process.env.BW_NOINTERACTION !== 'true';
|
||||||
|
if ((password == null || password === '') && canInteract) {
|
||||||
const answer: inquirer.Answers = await inquirer.createPromptModule({ output: process.stderr })({
|
const answer: inquirer.Answers = await inquirer.createPromptModule({ output: process.stderr })({
|
||||||
type: 'password',
|
type: 'password',
|
||||||
name: 'password',
|
name: 'password',
|
||||||
|
@ -15,7 +15,8 @@ export class UnlockCommand {
|
|||||||
private cryptoFunctionService: CryptoFunctionService) { }
|
private cryptoFunctionService: CryptoFunctionService) { }
|
||||||
|
|
||||||
async run(password: string, cmd: program.Command) {
|
async run(password: string, cmd: program.Command) {
|
||||||
if (password == null || password === '') {
|
const canInteract = process.stdout.isTTY && process.env.BW_NOINTERACTION !== 'true';
|
||||||
|
if ((password == null || password === '') && canInteract) {
|
||||||
const answer: inquirer.Answers = await inquirer.createPromptModule({ output: process.stderr })({
|
const answer: inquirer.Answers = await inquirer.createPromptModule({ output: process.stderr })({
|
||||||
type: 'password',
|
type: 'password',
|
||||||
name: 'password',
|
name: 'password',
|
||||||
|
@ -45,6 +45,7 @@ export class Program extends BaseProgram {
|
|||||||
.option('--raw', 'Return raw output instead of a descriptive message.')
|
.option('--raw', 'Return raw output instead of a descriptive message.')
|
||||||
.option('--response', 'Return a JSON formatted version of response output.')
|
.option('--response', 'Return a JSON formatted version of response output.')
|
||||||
.option('--quiet', 'Don\'t return anything to stdout.')
|
.option('--quiet', 'Don\'t return anything to stdout.')
|
||||||
|
.option('--nointeraction', 'Do not prompt for interactive user input.')
|
||||||
.option('--session <session>', 'Pass session key instead of reading from env.')
|
.option('--session <session>', 'Pass session key instead of reading from env.')
|
||||||
.version(this.main.platformUtilsService.getApplicationVersion(), '-v, --version');
|
.version(this.main.platformUtilsService.getApplicationVersion(), '-v, --version');
|
||||||
|
|
||||||
@ -64,6 +65,10 @@ export class Program extends BaseProgram {
|
|||||||
process.env.BW_RESPONSE = 'true';
|
process.env.BW_RESPONSE = 'true';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
program.on('option:nointeraction', () => {
|
||||||
|
process.env.BW_NOINTERACTION = 'true';
|
||||||
|
});
|
||||||
|
|
||||||
program.on('option:session', (key) => {
|
program.on('option:session', (key) => {
|
||||||
process.env.BW_SESSION = key;
|
process.env.BW_SESSION = key;
|
||||||
});
|
});
|
||||||
@ -640,7 +645,17 @@ export class Program extends BaseProgram {
|
|||||||
await this.exitIfNotAuthed();
|
await this.exitIfNotAuthed();
|
||||||
const hasKey = await this.main.cryptoService.hasKey();
|
const hasKey = await this.main.cryptoService.hasKey();
|
||||||
if (!hasKey) {
|
if (!hasKey) {
|
||||||
this.processResponse(Response.error('Vault is locked.'), true);
|
const canInteract = process.stdout.isTTY && process.env.BW_NOINTERACTION !== 'true';
|
||||||
|
if (canInteract) {
|
||||||
|
const command = new UnlockCommand(this.main.cryptoService, this.main.userService,
|
||||||
|
this.main.cryptoFunctionService);
|
||||||
|
const response = await command.run(null, null);
|
||||||
|
if (!response.success) {
|
||||||
|
this.processResponse(response, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.processResponse(Response.error('Vault is locked.'), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user