1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-02 18:17:46 +01:00

add unlock check option (#54) (#57)

This commit is contained in:
Estelle Poulin 2019-04-19 17:38:02 -04:00 committed by Kyle Spearrin
parent ddf3733f65
commit 89419c4fa5

View File

@ -119,11 +119,13 @@ export class Program extends BaseProgram {
writeLn('', true);
})
.action(async (email: string, password: string, cmd: program.Command) => {
await this.exitIfAuthed();
const command = new LoginCommand(this.main.authService, this.main.apiService,
this.main.cryptoFunctionService, this.main.syncService, this.main.i18nService);
const response = await command.run(email, password, cmd);
this.processResponse(response);
if (!cmd.check) {
await this.exitIfAuthed();
const command = new LoginCommand(this.main.authService, this.main.apiService,
this.main.cryptoFunctionService, this.main.syncService, this.main.i18nService);
const response = await command.run(email, password, cmd);
this.processResponse(response);
}
});
program
@ -176,12 +178,22 @@ export class Program extends BaseProgram {
writeLn(' bw unlock myPassword321 --raw');
writeLn('', true);
})
.option('--check', 'Check vault status.', async () => {
const locked = await this.main.lockService.isLocked();
if (!locked) {
const res = new MessageResponse('Vault is unlocked!', null);
this.processResponse(Response.success(res), true);
}
this.processResponse(Response.error('Vault is locked.'), true);
})
.action(async (password, cmd) => {
await this.exitIfNotAuthed();
const command = new UnlockCommand(this.main.cryptoService, this.main.userService,
this.main.cryptoFunctionService);
const response = await command.run(password, cmd);
this.processResponse(response);
if (!cmd.check) {
await this.exitIfNotAuthed();
const command = new UnlockCommand(this.main.cryptoService, this.main.userService,
this.main.cryptoFunctionService);
const response = await command.run(password, cmd);
this.processResponse(response);
}
});
program