mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-08 09:43:42 +01:00
Fix error when using password generator not logged in (#481)
* Do not fetch password policy if not logged in * Update deps
This commit is contained in:
parent
7ed67b69a6
commit
ff98f4ca6b
@ -1,4 +1,5 @@
|
|||||||
import { PasswordGenerationService } from "jslib-common/abstractions/passwordGeneration.service";
|
import { PasswordGenerationService } from "jslib-common/abstractions/passwordGeneration.service";
|
||||||
|
import { StateService } from "jslib-common/abstractions/state.service";
|
||||||
|
|
||||||
import { Response } from "jslib-node/cli/models/response";
|
import { Response } from "jslib-node/cli/models/response";
|
||||||
import { StringResponse } from "jslib-node/cli/models/response/stringResponse";
|
import { StringResponse } from "jslib-node/cli/models/response/stringResponse";
|
||||||
@ -6,7 +7,10 @@ import { StringResponse } from "jslib-node/cli/models/response/stringResponse";
|
|||||||
import { CliUtils } from "../utils";
|
import { CliUtils } from "../utils";
|
||||||
|
|
||||||
export class GenerateCommand {
|
export class GenerateCommand {
|
||||||
constructor(private passwordGenerationService: PasswordGenerationService) {}
|
constructor(
|
||||||
|
private passwordGenerationService: PasswordGenerationService,
|
||||||
|
private stateService: StateService
|
||||||
|
) {}
|
||||||
|
|
||||||
async run(cmdOptions: Record<string, any>): Promise<Response> {
|
async run(cmdOptions: Record<string, any>): Promise<Response> {
|
||||||
const normalizedOptions = new Options(cmdOptions);
|
const normalizedOptions = new Options(cmdOptions);
|
||||||
@ -22,9 +26,12 @@ export class GenerateCommand {
|
|||||||
capitalize: normalizedOptions.capitalize,
|
capitalize: normalizedOptions.capitalize,
|
||||||
includeNumber: normalizedOptions.includeNumber,
|
includeNumber: normalizedOptions.includeNumber,
|
||||||
};
|
};
|
||||||
const enforcedOptions =
|
|
||||||
await this.passwordGenerationService.enforcePasswordGeneratorPoliciesOnOptions(options);
|
const enforcedOptions = (await this.stateService.getIsAuthenticated())
|
||||||
const password = await this.passwordGenerationService.generatePassword(enforcedOptions[0]);
|
? (await this.passwordGenerationService.enforcePasswordGeneratorPoliciesOnOptions(options))[0]
|
||||||
|
: options;
|
||||||
|
|
||||||
|
const password = await this.passwordGenerationService.generatePassword(enforcedOptions);
|
||||||
const res = new StringResponse(password);
|
const res = new StringResponse(password);
|
||||||
return Response.success(res);
|
return Response.success(res);
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,10 @@ export class ServeCommand {
|
|||||||
this.main.cryptoService,
|
this.main.cryptoService,
|
||||||
this.main.apiService
|
this.main.apiService
|
||||||
);
|
);
|
||||||
this.generateCommand = new GenerateCommand(this.main.passwordGenerationService);
|
this.generateCommand = new GenerateCommand(
|
||||||
|
this.main.passwordGenerationService,
|
||||||
|
this.main.stateService
|
||||||
|
);
|
||||||
this.syncCommand = new SyncCommand(this.main.syncService);
|
this.syncCommand = new SyncCommand(this.main.syncService);
|
||||||
this.statusCommand = new StatusCommand(
|
this.statusCommand = new StatusCommand(
|
||||||
this.main.environmentService,
|
this.main.environmentService,
|
||||||
|
@ -322,7 +322,10 @@ export class Program extends BaseProgram {
|
|||||||
writeLn("", true);
|
writeLn("", true);
|
||||||
})
|
})
|
||||||
.action(async (options) => {
|
.action(async (options) => {
|
||||||
const command = new GenerateCommand(this.main.passwordGenerationService);
|
const command = new GenerateCommand(
|
||||||
|
this.main.passwordGenerationService,
|
||||||
|
this.main.stateService
|
||||||
|
);
|
||||||
const response = await command.run(options);
|
const response = await command.run(options);
|
||||||
this.processResponse(response);
|
this.processResponse(response);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user