WEB-562:fix(auth) align password validation with backend regex requirements (#2990)

fix the grammar
This commit is contained in:
Shubham Kumar
2026-01-12 12:50:08 -06:00
committed by GitHub
parent 1324a0fdcd
commit 43db2f2fba
4 changed files with 13 additions and 8 deletions
+10 -4
View File
@@ -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;
+1 -2
View File
@@ -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: [