From fa73c13b8c9ed35cbb9909e342b143fa8a57f1a0 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 25 Mar 2022 05:32:01 -0400 Subject: [PATCH] support for username gen website setting (#738) --- angular/src/components/password-generator.component.ts | 4 ++++ angular/src/services/jslib-services.module.ts | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/angular/src/components/password-generator.component.ts b/angular/src/components/password-generator.component.ts index 06e2442250..1ad6fd6316 100644 --- a/angular/src/components/password-generator.component.ts +++ b/angular/src/components/password-generator.component.ts @@ -29,6 +29,7 @@ export class PasswordGeneratorComponent implements OnInit { avoidAmbiguous = false; showWebsiteOption = false; enforcedPasswordPolicyOptions: PasswordGeneratorPolicyOptions; + usernameWebsite: string = null; constructor( protected passwordGenerationService: PasswordGenerationService, @@ -95,6 +96,9 @@ export class PasswordGeneratorComponent implements OnInit { if (!this.showWebsiteOption) { this.usernameOptions.subaddressType = this.usernameOptions.catchallType = "random"; } + if (this.usernameWebsite != null) { + this.usernameOptions.website = this.usernameWebsite; + } if (qParams.type === "username" || qParams.type === "password") { this.type = qParams.type; diff --git a/angular/src/services/jslib-services.module.ts b/angular/src/services/jslib-services.module.ts index 068b0ee3f9..d35deeb1a4 100644 --- a/angular/src/services/jslib-services.module.ts +++ b/angular/src/services/jslib-services.module.ts @@ -36,6 +36,7 @@ import { TokenService as TokenServiceAbstraction } from "jslib-common/abstractio import { TotpService as TotpServiceAbstraction } from "jslib-common/abstractions/totp.service"; import { TwoFactorService as TwoFactorServiceAbstraction } from "jslib-common/abstractions/twoFactor.service"; import { UserVerificationService as UserVerificationServiceAbstraction } from "jslib-common/abstractions/userVerification.service"; +import { UsernameGenerationService as UsernameGenerationServiceAbstraction } from "jslib-common/abstractions/usernameGeneration.service"; import { VaultTimeoutService as VaultTimeoutServiceAbstraction } from "jslib-common/abstractions/vaultTimeout.service"; import { StateFactory } from "jslib-common/factories/stateFactory"; import { Account } from "jslib-common/models/domain/account"; @@ -69,6 +70,7 @@ import { TokenService } from "jslib-common/services/token.service"; import { TotpService } from "jslib-common/services/totp.service"; import { TwoFactorService } from "jslib-common/services/twoFactor.service"; import { UserVerificationService } from "jslib-common/services/userVerification.service"; +import { UsernameGenerationService } from "jslib-common/services/usernameGeneration.service"; import { VaultTimeoutService } from "jslib-common/services/vaultTimeout.service"; import { WebCryptoFunctionService } from "jslib-common/services/webCryptoFunction.service"; @@ -198,6 +200,11 @@ import { ValidationService } from "./validation.service"; useClass: PasswordGenerationService, deps: [CryptoServiceAbstraction, PolicyServiceAbstraction, StateServiceAbstraction], }, + { + provide: UsernameGenerationServiceAbstraction, + useClass: UsernameGenerationService, + deps: [CryptoServiceAbstraction, StateServiceAbstraction], + }, { provide: ApiServiceAbstraction, useFactory: (