From a0cb1b03be6238b07b846a0ce81042a6ff28dcc9 Mon Sep 17 00:00:00 2001 From: Leonid Pershin Date: Thu, 2 Jul 2026 22:22:31 +0300 Subject: [PATCH] Refactor password validation regex for consistency across application - Updated password validation regex in ChangePasswordCommandValidator, RegisterCommandValidator, RegisterForm, and ChangePasswordForm to use Unicode property escapes for uppercase letters, ensuring consistent validation rules across both backend and frontend components. --- .../Auth/ChangePassword/ChangePasswordCommandValidator.cs | 2 +- .../Auth/Register/RegisterCommandValidator.cs | 2 +- frontend/src/features/auth/RegisterForm.tsx | 2 +- frontend/src/features/settings/ChangePasswordForm.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/PnvPanel.Application/Auth/ChangePassword/ChangePasswordCommandValidator.cs b/backend/src/PnvPanel.Application/Auth/ChangePassword/ChangePasswordCommandValidator.cs index 03d62be..0c83578 100644 --- a/backend/src/PnvPanel.Application/Auth/ChangePassword/ChangePasswordCommandValidator.cs +++ b/backend/src/PnvPanel.Application/Auth/ChangePassword/ChangePasswordCommandValidator.cs @@ -10,7 +10,7 @@ public sealed class ChangePasswordCommandValidator : AbstractValidator x.NewPassword) .NotEmpty() .MinimumLength(8) - .Matches("^(?=.*[A-Z])(?=.*[0-9]).+$") + .Matches(@"^(?=.*\p{Lu})(?=.*\d).+$") .WithMessage("Пароль должен содержать минимум одну заглавную букву и одну цифру."); } } diff --git a/backend/src/PnvPanel.Application/Auth/Register/RegisterCommandValidator.cs b/backend/src/PnvPanel.Application/Auth/Register/RegisterCommandValidator.cs index af11994..cef69f7 100644 --- a/backend/src/PnvPanel.Application/Auth/Register/RegisterCommandValidator.cs +++ b/backend/src/PnvPanel.Application/Auth/Register/RegisterCommandValidator.cs @@ -15,7 +15,7 @@ public sealed class RegisterCommandValidator : AbstractValidator x.Password) .NotEmpty() .MinimumLength(8) - .Matches("^(?=.*[A-Z])(?=.*[0-9]).+$") + .Matches(@"^(?=.*\p{Lu})(?=.*\d).+$") .WithMessage("Пароль должен содержать минимум одну заглавную букву и одну цифру."); } } diff --git a/frontend/src/features/auth/RegisterForm.tsx b/frontend/src/features/auth/RegisterForm.tsx index 16e8be9..d1fc4d2 100644 --- a/frontend/src/features/auth/RegisterForm.tsx +++ b/frontend/src/features/auth/RegisterForm.tsx @@ -18,7 +18,7 @@ const schema = z.object({ password: z .string() .min(8) - .regex(/^(?=.*[A-Z])(?=.*[0-9]).+$/), + .regex(/^(?=.*\p{Lu})(?=.*\d).+$/u), }) type FormValues = z.infer diff --git a/frontend/src/features/settings/ChangePasswordForm.tsx b/frontend/src/features/settings/ChangePasswordForm.tsx index e2794f4..e2abafa 100644 --- a/frontend/src/features/settings/ChangePasswordForm.tsx +++ b/frontend/src/features/settings/ChangePasswordForm.tsx @@ -15,7 +15,7 @@ const schema = z.object({ newPassword: z .string() .min(8) - .regex(/^(?=.*[A-Z])(?=.*[0-9]).+$/), + .regex(/^(?=.*\p{Lu})(?=.*\d).+$/u), }) type FormValues = z.infer