mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-29 23:48:52 +00:00
feat(console): getuserbyid, fix password policy validation, read iam (#233)
* remove displayname, show policy desc on patternerr * provide password complexity string, org create * user getuserbyid in userdetail, remove displayname * show multiple org domains * show zitadel project warnings, read iam * add missing ngondestroy impl
This commit is contained in:
@@ -74,13 +74,6 @@
|
||||
{{ 'USER.VALIDATION.REQUIRED' | translate }}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field class="formfield">
|
||||
<mat-label>{{ 'USER.PROFILE.DISPLAYNAME' | translate }}</mat-label>
|
||||
<input matInput formControlName="displayName" />
|
||||
<mat-error *ngIf="displayName?.invalid && displayName?.errors?.required">
|
||||
{{ 'USER.VALIDATION.REQUIRED' | translate }}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<p class="section">{{ 'USER.CREATE.GENDERLANGSECTION' | translate }}</p>
|
||||
|
||||
@@ -115,7 +108,10 @@
|
||||
type="password" />
|
||||
<mat-error *ngIf="password?.errors?.required">{{ 'USER.VALIDATION.REQUIRED' | translate }}
|
||||
</mat-error>
|
||||
<mat-error *ngIf="password?.errors?.pattern">{{ 'USER.VALIDATION.INVALIDPATTERN' | translate }}
|
||||
<mat-error *ngIf="password?.errors?.pattern">{{ policy | passwordPattern | translate }}
|
||||
</mat-error>
|
||||
<mat-error *ngIf="password?.errors?.minlength">
|
||||
{{ 'USER.VALIDATION.MINLENGTH' | translate:policy }}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field class="formfield">
|
||||
@@ -125,6 +121,11 @@
|
||||
<mat-error *ngIf="confirmPassword?.errors?.required">
|
||||
{{ 'USER.VALIDATION.REQUIRED' | translate }}
|
||||
</mat-error>
|
||||
<mat-error *ngIf="password?.errors?.pattern">{{ policy | passwordPattern | translate }}
|
||||
</mat-error>
|
||||
<mat-error *ngIf="password?.errors?.minlength">
|
||||
{{ 'USER.VALIDATION.MINLENGTH' | translate:policy }}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -4,7 +4,9 @@ import { Component } from '@angular/core';
|
||||
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { Router } from '@angular/router';
|
||||
import { CreateOrgRequest, CreateUserRequest, Gender, OrgSetUpResponse } from 'src/app/proto/generated/admin_pb';
|
||||
import { PasswordComplexityPolicy } from 'src/app/proto/generated/management_pb';
|
||||
import { AdminService } from 'src/app/services/admin.service';
|
||||
import { OrgService } from 'src/app/services/org.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
function passwordConfirmValidator(c: AbstractControl): any {
|
||||
@@ -44,28 +46,65 @@ export class OrgCreateComponent {
|
||||
|
||||
public genders: Gender[] = [Gender.GENDER_FEMALE, Gender.GENDER_MALE, Gender.GENDER_UNSPECIFIED];
|
||||
public languages: string[] = ['de', 'en'];
|
||||
|
||||
public policy!: PasswordComplexityPolicy.AsObject;
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private toast: ToastService,
|
||||
private adminService: AdminService,
|
||||
private _location: Location,
|
||||
private fb: FormBuilder,
|
||||
private orgService: OrgService,
|
||||
) {
|
||||
const validators: Validators[] = [Validators.required];
|
||||
|
||||
this.orgForm = this.fb.group({
|
||||
name: ['', [Validators.required]],
|
||||
domain: ['', [Validators.required]],
|
||||
});
|
||||
this.orgService.GetPasswordComplexityPolicy().then(data => {
|
||||
this.policy = data.toObject();
|
||||
if (this.policy.minLength) {
|
||||
validators.push(Validators.minLength(this.policy.minLength));
|
||||
}
|
||||
if (this.policy.hasLowercase) {
|
||||
validators.push(Validators.pattern(/[a-z]/g));
|
||||
}
|
||||
if (this.policy.hasUppercase) {
|
||||
validators.push(Validators.pattern(/[A-Z]/g));
|
||||
}
|
||||
if (this.policy.hasNumber) {
|
||||
validators.push(Validators.pattern(/[0-9]/g));
|
||||
}
|
||||
if (this.policy.hasSymbol) {
|
||||
// All characters that are not a digit or an English letter \W or a whitespace \S
|
||||
validators.push(Validators.pattern(/[\W\S]/));
|
||||
}
|
||||
|
||||
this.userForm = this.fb.group({
|
||||
firstName: ['', [Validators.required]],
|
||||
lastName: ['', [Validators.required]],
|
||||
displayName: [''],
|
||||
email: ['', [Validators.required]],
|
||||
gender: [''],
|
||||
nickName: [''],
|
||||
preferredLanguage: [''],
|
||||
password: ['', [Validators.required]],
|
||||
confirmPassword: ['', [Validators.required, passwordConfirmValidator]],
|
||||
this.userForm = this.fb.group({
|
||||
firstName: ['', [Validators.required]],
|
||||
lastName: ['', [Validators.required]],
|
||||
email: ['', [Validators.required]],
|
||||
gender: [''],
|
||||
nickName: [''],
|
||||
preferredLanguage: [''],
|
||||
password: ['', validators],
|
||||
confirmPassword: ['', [...validators, passwordConfirmValidator]],
|
||||
});
|
||||
}).catch(error => {
|
||||
console.log('no password complexity policy defined!');
|
||||
console.error(error);
|
||||
this.userForm = this.fb.group({
|
||||
firstName: ['', [Validators.required]],
|
||||
lastName: ['', [Validators.required]],
|
||||
email: ['', [Validators.required]],
|
||||
gender: [''],
|
||||
nickName: [''],
|
||||
preferredLanguage: [''],
|
||||
password: ['', validators],
|
||||
confirmPassword: ['', [...validators, passwordConfirmValidator]],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -82,7 +121,6 @@ export class OrgCreateComponent {
|
||||
registerUserRequest.setFirstName(this.firstName?.value);
|
||||
registerUserRequest.setLastName(this.lastName?.value);
|
||||
registerUserRequest.setNickName(this.nickName?.value);
|
||||
registerUserRequest.setDisplayName(this.displayName?.value);
|
||||
registerUserRequest.setGender(this.gender?.value);
|
||||
registerUserRequest.setPassword(this.password?.value);
|
||||
registerUserRequest.setPreferredLanguage(this.preferredLanguage?.value);
|
||||
@@ -122,10 +160,6 @@ export class OrgCreateComponent {
|
||||
return this.userForm.get('lastName');
|
||||
}
|
||||
|
||||
public get displayName(): AbstractControl | null {
|
||||
return this.userForm.get('displayName');
|
||||
}
|
||||
|
||||
public get email(): AbstractControl | null {
|
||||
return this.userForm.get('email');
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { MatInputModule } from '@angular/material/input';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||
import { HttpLoaderFactory } from 'src/app/app.module';
|
||||
import { PipesModule } from 'src/app/pipes/pipes.module';
|
||||
|
||||
import { OrgCreateRoutingModule } from './org-create-routing.module';
|
||||
import { OrgCreateComponent } from './org-create.component';
|
||||
@@ -25,6 +26,7 @@ import { OrgCreateComponent } from './org-create.component';
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
MatSelectModule,
|
||||
PipesModule,
|
||||
TranslateModule.forChild({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
|
||||
Reference in New Issue
Block a user