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
@@ -3,6 +3,7 @@ import { Component, OnInit, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { UntypedFormBuilder, Validators, ValidatorFn, AbstractControl, ValidationErrors } from '@angular/forms';
import { Subscription } from 'rxjs';
import { PasswordsUtility } from 'app/core/utils/passwords-utility';
/**
* Change Password Dialog component.
@@ -23,7 +24,8 @@ export class ChangePasswordDialogComponent implements OnInit {
*/
constructor(public dialogRef: MatDialogRef<ChangePasswordDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
private formBuilder: UntypedFormBuilder) { }
private formBuilder: UntypedFormBuilder,
private passwordsUtility: PasswordsUtility) { }
ngOnInit() {
this.createChangePasswordForm();
@@ -32,7 +34,7 @@ export class ChangePasswordDialogComponent implements OnInit {
/** Change Password form */
createChangePasswordForm() {
this.changePasswordForm = this.formBuilder.group({
'password': ['', [Validators.required, Validators.pattern('^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*[#$@$!%*?&])[A-Za-z\d#$@$!%*?&].{8,}$'), Validators.maxLength(50), Validators.minLength(8)]],
'password': ['', this.passwordsUtility.getPasswordValidators()],
'repeatPassword': ['', [Validators.required, this.confirmPassword('password')]]
});
}
@@ -0,0 +1,5 @@
<span (mouseenter)="mouseEnter()" (mouseleave)="mouseLeave()" *ngIf="!emptyValue">
<span class="m-l-3" *ngIf="isLongValue()"><fa-icon icon="eye" size="sm" [title]="textValue"></fa-icon></span>
<span class="m-l-5" *ngIf="isLongValue()">{{ textValue | truncateText:chars }}...</span>
<span class="m-l-5" *ngIf="!isLongValue()">{{ textValue }}</span>
</span>
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LongTextComponent } from './long-text.component';
describe('LongTextComponent', () => {
let component: LongTextComponent;
let fixture: ComponentFixture<LongTextComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ LongTextComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(LongTextComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,37 @@
import { Component, Input, OnInit } from '@angular/core';
@Component({
selector: 'mifosx-long-text',
templateUrl: './long-text.component.html',
styleUrls: ['./long-text.component.scss']
})
export class LongTextComponent implements OnInit {
@Input() textValue: string;
@Input() chars = 30;
iconVisible = false;
displayL = false;
displayR = true;
emptyValue = false;
constructor() { }
ngOnInit(): void {
this.emptyValue = (!this.textValue || this.textValue === '');
}
isLongValue(): boolean {
if (this.textValue == null) {
return false;
}
return (this.textValue.length > 25);
}
mouseEnter() {
this.iconVisible = true;
}
mouseLeave() {
this.iconVisible = false;
}
}
+5 -2
View File
@@ -47,6 +47,7 @@ import { GlAccountSelectorComponent } from './accounting/gl-account-selector/gl-
import { GlAccountDisplayComponent } from './accounting/gl-account-display/gl-account-display.component';
import { ViewSavingsAccountingDetailsComponent } from './accounting/view-savings-accounting-details/view-savings-accounting-details.component';
import { ThemeToggleComponent } from './theme-toggle/theme-toggle.component';
import { LongTextComponent } from './long-text/long-text.component';
/**
* Shared Module
@@ -100,7 +101,8 @@ import { ThemeToggleComponent } from './theme-toggle/theme-toggle.component';
GlAccountSelectorComponent,
GlAccountDisplayComponent,
ViewSavingsAccountingDetailsComponent,
ThemeToggleComponent
ThemeToggleComponent,
LongTextComponent
],
exports: [
FileUploadComponent,
@@ -132,7 +134,8 @@ import { ThemeToggleComponent } from './theme-toggle/theme-toggle.component';
GlAccountSelectorComponent,
GlAccountDisplayComponent,
ViewSavingsAccountingDetailsComponent,
ThemeToggleComponent
ThemeToggleComponent,
LongTextComponent
]
})
export class SharedModule { }