1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-14 02:08:50 +02:00

Fix unlock env and passwordfile (#352)

* Handle null options

* Pass in ConsoleLogService dependency
This commit is contained in:
Matt Gibson 2021-07-20 10:54:04 -04:00 committed by GitHub
parent f0c1f1b16b
commit 230e00e423
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View File

@ -18,19 +18,17 @@ import { NodeUtils } from 'jslib-common/misc/nodeUtils';
import { ConsoleLogService } from 'jslib-common/services/consoleLog.service';
export class UnlockCommand {
private logService: ConsoleLogService;
constructor(private cryptoService: CryptoService, private userService: UserService,
private cryptoFunctionService: CryptoFunctionService, private apiService: ApiService) {
this.logService = new ConsoleLogService(false);
private cryptoFunctionService: CryptoFunctionService, private apiService: ApiService,
private logService: ConsoleLogService) {
}
async run(password: string, options: program.OptionValues) {
const canInteract = process.env.BW_NOINTERACTION !== 'true';
if (password == null || password === '') {
if (options.passwordfile) {
if (options?.passwordfile) {
password = await NodeUtils.readFirstLine(options.passwordfile);
} else if (options.passwordenv) {
} else if (options?.passwordenv) {
if (process.env[options.passwordenv]) {
password = process.env[options.passwordenv];
} else {

View File

@ -208,7 +208,7 @@ export class Program extends BaseProgram {
if (!cmd.check) {
await this.exitIfNotAuthed();
const command = new UnlockCommand(this.main.cryptoService, this.main.userService,
this.main.cryptoFunctionService, this.main.apiService);
this.main.cryptoFunctionService, this.main.apiService, this.main.logService);
const response = await command.run(password, cmd);
this.processResponse(response);
}
@ -412,7 +412,7 @@ export class Program extends BaseProgram {
const canInteract = process.env.BW_NOINTERACTION !== 'true';
if (canInteract) {
const command = new UnlockCommand(this.main.cryptoService, this.main.userService,
this.main.cryptoFunctionService, this.main.apiService);
this.main.cryptoFunctionService, this.main.apiService, this.main.logService);
const response = await command.run(null, null);
if (!response.success) {
this.processResponse(response, true);