Browse Source

chore: pass injector to getPasswordValidators

pull/6156/head
mehmet-erim 6 years ago
parent
commit
fd26ba4a40
  1. 5
      npm/ng-packs/packages/account/src/lib/components/change-password/change-password.component.ts
  2. 5
      npm/ng-packs/packages/account/src/lib/components/register/register.component.ts
  3. 13
      npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts

5
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 { ChangePassword, ProfileState } from '@abp/ng.core';
import { getPasswordValidators, ToasterService } from '@abp/ng.theme.shared'; 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 { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { comparePasswords, Validation } from '@ngx-validate/core'; import { comparePasswords, Validation } from '@ngx-validate/core';
import { Store } from '@ngxs/store'; import { Store } from '@ngxs/store';
@ -32,6 +32,7 @@ export class ChangePasswordComponent
}; };
constructor( constructor(
private injector: Injector,
private fb: FormBuilder, private fb: FormBuilder,
private store: Store, private store: Store,
private toasterService: ToasterService, private toasterService: ToasterService,
@ -40,7 +41,7 @@ export class ChangePasswordComponent
ngOnInit(): void { ngOnInit(): void {
this.hideCurrentPassword = !this.store.selectSnapshot(ProfileState.getProfile).hasPassword; this.hideCurrentPassword = !this.store.selectSnapshot(ProfileState.getProfile).hasPassword;
const passwordValidations = getPasswordValidators(this.store); const passwordValidations = getPasswordValidators(this.injector);
this.form = this.fb.group( this.form = this.fb.group(
{ {

5
npm/ng-packs/packages/account/src/lib/components/register/register.component.ts

@ -1,6 +1,6 @@
import { AuthService, ConfigState } from '@abp/ng.core'; import { AuthService, ConfigState } from '@abp/ng.core';
import { getPasswordValidators, ToasterService } from '@abp/ng.theme.shared'; 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 { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Store } from '@ngxs/store'; import { Store } from '@ngxs/store';
import { OAuthService } from 'angular-oauth2-oidc'; import { OAuthService } from 'angular-oauth2-oidc';
@ -26,6 +26,7 @@ export class RegisterComponent implements OnInit {
authWrapperKey = eAccountComponents.AuthWrapper; authWrapperKey = eAccountComponents.AuthWrapper;
constructor( constructor(
private injector: Injector,
private fb: FormBuilder, private fb: FormBuilder,
private accountService: AccountService, private accountService: AccountService,
private oauthService: OAuthService, private oauthService: OAuthService,
@ -55,7 +56,7 @@ export class RegisterComponent implements OnInit {
this.form = this.fb.group({ this.form = this.fb.group({
username: ['', [required, maxLength(255)]], username: ['', [required, maxLength(255)]],
password: ['', [required, ...getPasswordValidators(this.store)]], password: ['', [required, ...getPasswordValidators(this.injector)]],
email: ['', [required, email]], email: ['', [required, email]],
}); });
} }

13
npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts

@ -1,7 +1,14 @@
import { ListService } from '@abp/ng.core'; import { ListService } from '@abp/ng.core';
import { ePermissionManagementComponents } from '@abp/ng.permission-management'; import { ePermissionManagementComponents } from '@abp/ng.permission-management';
import { Confirmation, ConfirmationService, getPasswordValidators } from '@abp/ng.theme.shared'; 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 { import {
AbstractControl, AbstractControl,
FormArray, FormArray,
@ -23,7 +30,6 @@ import {
UpdateUser, UpdateUser,
} from '../../actions/identity.actions'; } from '../../actions/identity.actions';
import { Identity } from '../../models/identity'; import { Identity } from '../../models/identity';
import { IdentityRoleService } from '../../proxy/identity/identity-role.service';
import { IdentityUserService } from '../../proxy/identity/identity-user.service'; import { IdentityUserService } from '../../proxy/identity/identity-user.service';
import { import {
GetIdentityUsersInput, GetIdentityUsersInput,
@ -78,6 +84,7 @@ export class UsersComponent implements OnInit {
constructor( constructor(
public readonly list: ListService<GetIdentityUsersInput>, public readonly list: ListService<GetIdentityUsersInput>,
private injector: Injector,
private confirmationService: ConfirmationService, private confirmationService: ConfirmationService,
private fb: FormBuilder, private fb: FormBuilder,
private store: Store, 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])); this.form.addControl('password', new FormControl('', [...passwordValidators]));

Loading…
Cancel
Save