|
|
|
@ -19,7 +19,14 @@ import { Store } from '@ngrx/store'; |
|
|
|
import { AppState } from '@core/core.state'; |
|
|
|
import { PageComponent } from '@shared/components/page.component'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms'; |
|
|
|
import { |
|
|
|
AbstractControl, |
|
|
|
UntypedFormBuilder, |
|
|
|
UntypedFormControl, |
|
|
|
UntypedFormGroup, ValidationErrors, |
|
|
|
ValidatorFn, |
|
|
|
Validators |
|
|
|
} from '@angular/forms'; |
|
|
|
import { JwtSettings, SecuritySettings } from '@shared/models/settings.models'; |
|
|
|
import { AdminService } from '@core/http/admin.service'; |
|
|
|
import { HasConfirmForm } from '@core/guards/confirm-on-exit.guard'; |
|
|
|
@ -67,14 +74,16 @@ export class SecuritySettingsComponent extends PageComponent implements HasConfi |
|
|
|
userLockoutNotificationEmail: ['', []], |
|
|
|
passwordPolicy: this.fb.group( |
|
|
|
{ |
|
|
|
minimumLength: [null, [Validators.required, Validators.min(5), Validators.max(50)]], |
|
|
|
minimumLength: [null, [Validators.required, Validators.min(6), Validators.max(50)]], |
|
|
|
maximumLength: [null, [Validators.min(6), this.maxPasswordValidation()]], |
|
|
|
minimumUppercaseLetters: [null, Validators.min(0)], |
|
|
|
minimumLowercaseLetters: [null, Validators.min(0)], |
|
|
|
minimumDigits: [null, Validators.min(0)], |
|
|
|
minimumSpecialCharacters: [null, Validators.min(0)], |
|
|
|
passwordExpirationPeriodDays: [null, Validators.min(0)], |
|
|
|
passwordReuseFrequencyDays: [null, Validators.min(0)], |
|
|
|
allowWhitespaces: [true] |
|
|
|
allowWhitespaces: [true], |
|
|
|
forceUserToResetPasswordIfNotValid: [false] |
|
|
|
} |
|
|
|
) |
|
|
|
}); |
|
|
|
@ -113,6 +122,18 @@ export class SecuritySettingsComponent extends PageComponent implements HasConfi |
|
|
|
})).subscribe(() => {}); |
|
|
|
} |
|
|
|
|
|
|
|
private maxPasswordValidation(): ValidatorFn { |
|
|
|
return (control: AbstractControl): ValidationErrors | null => { |
|
|
|
const value: string = control.value; |
|
|
|
if (value) { |
|
|
|
if (value < this.securitySettingsFormGroup.get('passwordPolicy.minimumLength').value) { |
|
|
|
return {lessMin: true}; |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
discardSetting() { |
|
|
|
this.securitySettingsFormGroup.reset(this.securitySettings); |
|
|
|
} |
|
|
|
|