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