mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-05 09:10:53 +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 { StateService } from "jslib-common/abstractions/state.service";
|
||||
|
||||
import { Response } from "jslib-node/cli/models/response";
|
||||
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";
|
||||
|
||||
export class GenerateCommand {
|
||||
constructor(private passwordGenerationService: PasswordGenerationService) {}
|
||||
constructor(
|
||||
private passwordGenerationService: PasswordGenerationService,
|
||||
private stateService: StateService
|
||||
) {}
|
||||
|
||||
async run(cmdOptions: Record<string, any>): Promise<Response> {
|
||||
const normalizedOptions = new Options(cmdOptions);
|
||||
@ -22,9 +26,12 @@ export class GenerateCommand {
|
||||
capitalize: normalizedOptions.capitalize,
|
||||
includeNumber: normalizedOptions.includeNumber,
|
||||
};
|
||||
const enforcedOptions =
|
||||
await this.passwordGenerationService.enforcePasswordGeneratorPoliciesOnOptions(options);
|
||||
const password = await this.passwordGenerationService.generatePassword(enforcedOptions[0]);
|
||||
|
||||
const enforcedOptions = (await this.stateService.getIsAuthenticated())
|
||||
? (await this.passwordGenerationService.enforcePasswordGeneratorPoliciesOnOptions(options))[0]
|
||||
: options;
|
||||
|
||||
const password = await this.passwordGenerationService.generatePassword(enforcedOptions);
|
||||
const res = new StringResponse(password);
|
||||
return Response.success(res);
|
||||
}
|
||||
|
@ -84,7 +84,10 @@ export class ServeCommand {
|
||||
this.main.cryptoService,
|
||||
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.statusCommand = new StatusCommand(
|
||||
this.main.environmentService,
|
||||
|
@ -322,7 +322,10 @@ export class Program extends BaseProgram {
|
||||
writeLn("", true);
|
||||
})
|
||||
.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);
|
||||
this.processResponse(response);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user