Browse Source
Merge pull request #13653 from abpframework/issue/11463
Add userName validatior on Identit/user.component
pull/13690/head
Gizem Mutu Kurt
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
16 additions and
5 deletions
-
npm/ng-packs/packages/identity/src/lib/components/users/users.component.html
-
npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts
-
npm/ng-packs/packages/identity/src/lib/defaults/default-users-entity-actions.ts
-
npm/ng-packs/packages/identity/src/lib/defaults/default-users-form-props.ts
|
|
|
@ -39,7 +39,7 @@ |
|
|
|
><div class="text-center"><i class="fa fa-pulse fa-spinner"></i></div |
|
|
|
></ng-template> |
|
|
|
|
|
|
|
<form *ngIf="form; else loaderRef" [formGroup]="form" (ngSubmit)="save()"> |
|
|
|
<form *ngIf="form; else loaderRef" [blueprints]="blueprints" [formGroup]="form" (ngSubmit)="save()"> |
|
|
|
<ul ngbNav #nav="ngbNav" class="nav-tabs"> |
|
|
|
<li ngbNavItem> |
|
|
|
<a ngbNavLink>{{ 'AbpIdentity::UserInformations' | abpLocalization }}</a> |
|
|
|
|
|
|
|
@ -61,6 +61,9 @@ export class UsersComponent implements OnInit { |
|
|
|
|
|
|
|
entityDisplayName: string; |
|
|
|
|
|
|
|
blueprints = { pattern: 'AbpIdentity::Volo.Abp.Identity:InvalidUserName[{{ actualValue }}]' }; |
|
|
|
|
|
|
|
|
|
|
|
trackByFn: TrackByFunction<AbstractControl> = (index, item) => Object.keys(item)[0] || index; |
|
|
|
|
|
|
|
onVisiblePermissionChange = event => { |
|
|
|
|
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
import { IdentityUserDto } from '@abp/ng.identity/proxy'; |
|
|
|
import {IdentityUserDto} from '@abp/ng.identity/proxy'; |
|
|
|
import { EntityAction } from '@abp/ng.theme.shared/extensions'; |
|
|
|
import { UsersComponent } from '../components/users/users.component'; |
|
|
|
import {ConfigStateService, CurrentUserDto} from "@abp/ng.core"; |
|
|
|
|
|
|
|
export const DEFAULT_USERS_ENTITY_ACTIONS = EntityAction.createMany<IdentityUserDto>([ |
|
|
|
{ |
|
|
|
@ -18,13 +19,18 @@ export const DEFAULT_USERS_ENTITY_ACTIONS = EntityAction.createMany<IdentityUser |
|
|
|
component.openPermissionsModal(data.record.id, data.record.userName); |
|
|
|
}, |
|
|
|
permission: 'AbpIdentity.Users.ManagePermissions', |
|
|
|
}, |
|
|
|
{ |
|
|
|
}, { |
|
|
|
text: 'AbpIdentity::Delete', |
|
|
|
action: data => { |
|
|
|
const component = data.getInjected(UsersComponent); |
|
|
|
component.delete(data.record.id, data.record.name || data.record.userName); |
|
|
|
}, |
|
|
|
visible: data => { |
|
|
|
const userName = data.record.userName; |
|
|
|
const configStateService = data.getInjected(ConfigStateService) |
|
|
|
const currentUser = configStateService.getOne("currentUser") as CurrentUserDto; |
|
|
|
return userName !== currentUser.userName; |
|
|
|
}, |
|
|
|
permission: 'AbpIdentity.Users.Delete', |
|
|
|
}, |
|
|
|
]); |
|
|
|
|
|
|
|
@ -3,13 +3,15 @@ import { getPasswordValidators } from '@abp/ng.theme.shared'; |
|
|
|
import { ePropType, FormProp } from '@abp/ng.theme.shared/extensions'; |
|
|
|
import { Validators } from '@angular/forms'; |
|
|
|
|
|
|
|
const onlyLetterAndNumberRegex = /^[a-zA-Z0-9]+$/; |
|
|
|
|
|
|
|
export const DEFAULT_USERS_CREATE_FORM_PROPS = FormProp.createMany<IdentityUserDto>([ |
|
|
|
{ |
|
|
|
type: ePropType.String, |
|
|
|
name: 'userName', |
|
|
|
displayName: 'AbpIdentity::UserName', |
|
|
|
id: 'user-name', |
|
|
|
validators: () => [Validators.required, Validators.maxLength(256)], |
|
|
|
validators: () => [Validators.required, Validators.maxLength(256), Validators.pattern(onlyLetterAndNumberRegex)], |
|
|
|
}, |
|
|
|
{ |
|
|
|
type: ePropType.Password, |
|
|
|
|