From 64381cbae0495658fd134452ecab080b5c6eb1b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=A8=20Audrey=20=E2=9C=A8?= Date: Fri, 9 Feb 2024 11:33:52 -0500 Subject: [PATCH] check credential type explicitly when loading evaluator (#7791) --- .../password/password-generation.service.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libs/common/src/tools/generator/password/password-generation.service.ts b/libs/common/src/tools/generator/password/password-generation.service.ts index 831ec20278..0b37e81fdc 100644 --- a/libs/common/src/tools/generator/password/password-generation.service.ts +++ b/libs/common/src/tools/generator/password/password-generation.service.ts @@ -195,9 +195,10 @@ export class PasswordGenerationService implements PasswordGenerationServiceAbstr options.type = policy.defaultType; } - const evaluator = options.type - ? new PasswordGeneratorOptionsEvaluator(policy) - : new PassphraseGeneratorOptionsEvaluator(policy); + const evaluator = + options.type == "password" + ? new PasswordGeneratorOptionsEvaluator(policy) + : new PassphraseGeneratorOptionsEvaluator(policy); // Ensure the options to pass the current rules const withPolicy = evaluator.applyPolicy(options); @@ -344,9 +345,10 @@ export class PasswordGenerationService implements PasswordGenerationServiceAbstr options: PasswordGeneratorOptions, enforcedPolicyOptions: PasswordGeneratorPolicyOptions, ) { - const evaluator = options.type - ? new PasswordGeneratorOptionsEvaluator(enforcedPolicyOptions) - : new PassphraseGeneratorOptionsEvaluator(enforcedPolicyOptions); + const evaluator = + options.type == "password" + ? new PasswordGeneratorOptionsEvaluator(enforcedPolicyOptions) + : new PassphraseGeneratorOptionsEvaluator(enforcedPolicyOptions); const evaluatedOptions = evaluator.applyPolicy(options); const santizedOptions = evaluator.sanitize(evaluatedOptions);