From fd26ba4a40674638c8953820dbeca06f613abe6a Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Wed, 11 Nov 2020 14:49:44 +0300 Subject: [PATCH] chore: pass injector to getPasswordValidators --- .../change-password/change-password.component.ts | 5 +++-- .../lib/components/register/register.component.ts | 5 +++-- .../src/lib/components/users/users.component.ts | 13 ++++++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/npm/ng-packs/packages/account/src/lib/components/change-password/change-password.component.ts b/npm/ng-packs/packages/account/src/lib/components/change-password/change-password.component.ts index 84e87f7ce7..de5cd23c89 100644 --- a/npm/ng-packs/packages/account/src/lib/components/change-password/change-password.component.ts +++ b/npm/ng-packs/packages/account/src/lib/components/change-password/change-password.component.ts @@ -1,6 +1,6 @@ import { ChangePassword, ProfileState } from '@abp/ng.core'; import { getPasswordValidators, ToasterService } from '@abp/ng.theme.shared'; -import { Component, OnInit } from '@angular/core'; +import { Component, Injector, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; import { comparePasswords, Validation } from '@ngx-validate/core'; import { Store } from '@ngxs/store'; @@ -32,6 +32,7 @@ export class ChangePasswordComponent }; constructor( + private injector: Injector, private fb: FormBuilder, private store: Store, private toasterService: ToasterService, @@ -40,7 +41,7 @@ export class ChangePasswordComponent ngOnInit(): void { this.hideCurrentPassword = !this.store.selectSnapshot(ProfileState.getProfile).hasPassword; - const passwordValidations = getPasswordValidators(this.store); + const passwordValidations = getPasswordValidators(this.injector); this.form = this.fb.group( { diff --git a/npm/ng-packs/packages/account/src/lib/components/register/register.component.ts b/npm/ng-packs/packages/account/src/lib/components/register/register.component.ts index 32dc096748..ea313cc30e 100644 --- a/npm/ng-packs/packages/account/src/lib/components/register/register.component.ts +++ b/npm/ng-packs/packages/account/src/lib/components/register/register.component.ts @@ -1,6 +1,6 @@ import { AuthService, ConfigState } from '@abp/ng.core'; import { getPasswordValidators, ToasterService } from '@abp/ng.theme.shared'; -import { Component, OnInit } from '@angular/core'; +import { Component, Injector, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { Store } from '@ngxs/store'; import { OAuthService } from 'angular-oauth2-oidc'; @@ -26,6 +26,7 @@ export class RegisterComponent implements OnInit { authWrapperKey = eAccountComponents.AuthWrapper; constructor( + private injector: Injector, private fb: FormBuilder, private accountService: AccountService, private oauthService: OAuthService, @@ -55,7 +56,7 @@ export class RegisterComponent implements OnInit { this.form = this.fb.group({ username: ['', [required, maxLength(255)]], - password: ['', [required, ...getPasswordValidators(this.store)]], + password: ['', [required, ...getPasswordValidators(this.injector)]], email: ['', [required, email]], }); } diff --git a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts index 5b36b7351e..c302b14cea 100644 --- a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts +++ b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts @@ -1,7 +1,14 @@ import { ListService } from '@abp/ng.core'; import { ePermissionManagementComponents } from '@abp/ng.permission-management'; import { Confirmation, ConfirmationService, getPasswordValidators } from '@abp/ng.theme.shared'; -import { Component, OnInit, TemplateRef, TrackByFunction, ViewChild } from '@angular/core'; +import { + Component, + Injector, + OnInit, + TemplateRef, + TrackByFunction, + ViewChild, +} from '@angular/core'; import { AbstractControl, FormArray, @@ -23,7 +30,6 @@ import { UpdateUser, } from '../../actions/identity.actions'; import { Identity } from '../../models/identity'; -import { IdentityRoleService } from '../../proxy/identity/identity-role.service'; import { IdentityUserService } from '../../proxy/identity/identity-user.service'; import { GetIdentityUsersInput, @@ -78,6 +84,7 @@ export class UsersComponent implements OnInit { constructor( public readonly list: ListService, + private injector: Injector, private confirmationService: ConfirmationService, private fb: FormBuilder, private store: Store, @@ -115,7 +122,7 @@ export class UsersComponent implements OnInit { ), }); - const passwordValidators = getPasswordValidators(this.store); + const passwordValidators = getPasswordValidators(this.injector); this.form.addControl('password', new FormControl('', [...passwordValidators]));