Strongest password policy

This commit is contained in:
Jose Alberto Hernandez
2024-05-06 21:09:31 -06:00
committed by Jose Alberto Hernandez
parent 9b17a6c4f8
commit 8fdf8fb10c
35 changed files with 283 additions and 79 deletions
@@ -67,6 +67,15 @@
<mat-error *ngIf="userForm.controls.password.hasError('required')">
{{'labels.inputs.Password' | translate}} {{"labels.commons.is" | translate}} <strong>{{"labels.commons.required" | translate}}</strong>
</mat-error>
<mat-error *ngIf="userForm.controls.password.hasError('minlength')">
{{'labels.commons.Password should be at least' | translate }} <strong>{{'labels.commons.8 characters long' | translate }}</strong>
</mat-error>
<mat-error *ngIf="userForm.controls.password.hasError('maxlength')">
{{'labels.commons.Password should not be more than' | translate }} <strong>{{'labels.commons.50 characters long' | translate }}</strong>
</mat-error>
<mat-error *ngIf="userForm.controls.password.hasError('pattern') && !(userForm.controls.password.hasError('minlength') || userForm.controls.password.hasError('maxlength'))">
{{'labels.commons.Password should include a' | translate }} <strong>{{'labels.commons.numeral' | translate }}</strong> {{'labels.commons.and at' | translate }} <strong>{{'labels.commons.least one uppercase' | translate }}</strong> ,<strong>{{'labels.commons.lowercase and special character' | translate }}</strong>
</mat-error>
</mat-form-field>
<mat-form-field fxFlex="48%" *ngIf="!userForm.controls.sendPasswordToEmail.value">
@@ -79,7 +88,7 @@
<p fxFlex="98%" class="reset-password-error" *ngIf="userForm.errors?.passwordsDoNotMatch &&
(!userForm.controls.password.hasError('required') && !userForm.controls.repeatPassword.hasError('required'))">
{{'labels.inputs.Passwords' | translate}} <strong>{{"labels.commons.do not match' | translate}}</strong>
{{'labels.inputs.Passwords' | translate}} <strong>{{'labels.commons.do not match' | translate}}</strong>
</p>
<mat-form-field fxFlex="48%">
@@ -8,13 +8,12 @@ import { MatDialog } from '@angular/material/dialog';
/** Custom Services */
import { UsersService } from '../users.service';
import { PopoverService } from '../../configuration-wizard/popover/popover.service';
import { ConfigurationWizardService } from '../../configuration-wizard/configuration-wizard.service';
/** Custom Validators */
import { confirmPasswordValidator } from '../../login/reset-password/confirm-password.validator';
/** Custom Dialog Component */
import { ContinueSetupDialogComponent } from '../../configuration-wizard/continue-setup-dialog/continue-setup-dialog.component';
import { PasswordsUtility } from 'app/core/utils/passwords-utility';
import { confirmPasswordValidator } from 'app/login/reset-password/confirm-password.validator';
import { ConfigurationWizardService } from 'app/configuration-wizard/configuration-wizard.service';
import { ContinueSetupDialogComponent } from 'app/configuration-wizard/continue-setup-dialog/continue-setup-dialog.component';
/**
* Create user component.
@@ -55,7 +54,8 @@ export class CreateUserComponent implements OnInit, AfterViewInit {
private router: Router,
private popoverService: PopoverService,
private configurationWizardService: ConfigurationWizardService,
public dialog: MatDialog) {
private dialog: MatDialog,
private passwordsUtility: PasswordsUtility) {
this.route.data.subscribe((data: {
usersTemplate: any
}) => {
@@ -112,8 +112,8 @@ export class CreateUserComponent implements OnInit, AfterViewInit {
this.userForm.removeControl('repeatPassword');
this.userForm.get('email').setValidators([Validators.required, Validators.email]);
} else {
this.userForm.addControl('password', new UntypedFormControl('', Validators.required));
this.userForm.addControl('repeatPassword', new UntypedFormControl('', Validators.required));
this.userForm.addControl('password', new UntypedFormControl('', this.passwordsUtility.getPasswordValidators()));
this.userForm.addControl('repeatPassword', new UntypedFormControl('', [Validators.required, this.passwordsUtility.confirmPassword('password')]));
this.userForm.get('email').setValidators([Validators.email]);
}
this.userForm.get('email').updateValueAndValidity();