WEB-562:fix(auth) align password validation with backend regex requirements (#2990)
fix the grammar
This commit is contained in:
@@ -31,11 +31,17 @@ export function passwordValidator(): ValidatorFn {
|
||||
if (!/\d/.test(value)) {
|
||||
errors['number'] = 'Password must contain at least one number';
|
||||
}
|
||||
if (!/^(?:(.)(?!\1))+$/.test(value)) {
|
||||
errors['repeated'] = 'Password must have not consecutive repeating characters';
|
||||
// Check for consecutive repeating characters (e.g., aa, 11, @@)
|
||||
if (/(.)\1/.test(value)) {
|
||||
errors['repeated'] = 'Password must not have consecutive repeating characters';
|
||||
}
|
||||
if (!/[@$!%*?&]/.test(value)) {
|
||||
errors['specialChar'] = 'Password must contain at least one special character (@$!%*?&)';
|
||||
// Check for any special character (non-alphanumeric, non-space)
|
||||
if (!/[^\w\s]/.test(value)) {
|
||||
errors['specialChar'] = 'Password must contain at least one special character';
|
||||
}
|
||||
// Check for spaces
|
||||
if (/\s/.test(value)) {
|
||||
errors['spaces'] = 'Password must not contain spaces';
|
||||
}
|
||||
|
||||
return Object.keys(errors).length > 0 ? errors : null;
|
||||
|
||||
@@ -17,9 +17,8 @@ import { environment } from '../../../environments/environment';
|
||||
})
|
||||
export class PasswordsUtility {
|
||||
minPasswordLength: number = environment.minPasswordLength | 12;
|
||||
// password regex pattern
|
||||
public static PASSWORD_REGEX =
|
||||
'^(?!.*(.)\\1{1,})(?!.*\\s)(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^\\w\\s]).{' +
|
||||
'^(?!.*(.)\\1)(?!.*\\s)(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^\\w\\s]).{' +
|
||||
(environment.minPasswordLength | 12) +
|
||||
',50}$';
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ export class ChangePasswordDialogComponent implements OnInit {
|
||||
Validators.required,
|
||||
Validators.minLength(this.minPasswordLength),
|
||||
Validators.maxLength(50),
|
||||
Validators.pattern(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).+$/)
|
||||
Validators.pattern(/^(?!.*(.)\1)(?!.*\s)(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s]).+$/)
|
||||
]
|
||||
],
|
||||
repeatPassword: [
|
||||
|
||||
@@ -149,7 +149,7 @@ export class CreateUserComponent implements OnInit, AfterViewInit {
|
||||
Validators.required,
|
||||
Validators.minLength(12),
|
||||
Validators.maxLength(50),
|
||||
Validators.pattern(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).+$/)
|
||||
Validators.pattern(/^(?!.*(.)\1)(?!.*\s)(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s]).+$/)
|
||||
]
|
||||
],
|
||||
repeatPassword: [
|
||||
|
||||
Reference in New Issue
Block a user