From bc227b0c603d45cd23025ea26ba9e228ce51e597 Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Wed, 11 Nov 2020 14:49:11 +0300 Subject: [PATCH] refactor: changed the getPasswordValidators fn argument --- .../src/lib/utils/validation-utils.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/npm/ng-packs/packages/theme-shared/src/lib/utils/validation-utils.ts b/npm/ng-packs/packages/theme-shared/src/lib/utils/validation-utils.ts index 966135fad7..a9ec1d4270 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/utils/validation-utils.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/utils/validation-utils.ts @@ -1,12 +1,12 @@ -import { Store } from '@ngxs/store'; -import { ABP, ConfigState } from '@abp/ng.core'; +import { ABP, ConfigStateService } from '@abp/ng.core'; +import { Injector } from '@angular/core'; +import { ValidatorFn, Validators } from '@angular/forms'; import { PasswordRules, validatePassword } from '@ngx-validate/core'; -import { Validators, ValidatorFn } from '@angular/forms'; const { minLength, maxLength } = Validators; -export function getPasswordValidators(store: Store): ValidatorFn[] { - const getRule = getRuleFn(store); +export function getPasswordValidators(injector: Injector): ValidatorFn[] { + const getRule = getRuleFn(injector); const passwordRulesArr = [] as PasswordRules; let requiredLength = 1; @@ -34,11 +34,11 @@ export function getPasswordValidators(store: Store): ValidatorFn[] { return [validatePassword(passwordRulesArr), minLength(requiredLength), maxLength(128)]; } -function getRuleFn(store: Store) { +function getRuleFn(injector: Injector) { + const configState = injector.get(ConfigStateService); + return (key: string) => { - const passwordRules: ABP.Dictionary = store.selectSnapshot( - ConfigState.getSettings('Identity.Password'), - ); + const passwordRules: ABP.Dictionary = configState.getSettings('Identity.Password'); return (passwordRules[`Abp.Identity.Password.${key}`] || '').toLowerCase(); };