diff --git a/Endpoint/Controllers/Configuration/SetupController.cs b/Endpoint/Controllers/Configuration/SetupController.cs index 7ccea5f..92ec9b6 100644 --- a/Endpoint/Controllers/Configuration/SetupController.cs +++ b/Endpoint/Controllers/Configuration/SetupController.cs @@ -33,7 +33,7 @@ namespace Mirea.Api.Endpoint.Controllers.Configuration; [ApiController] [MaintenanceModeIgnore] [ApiExplorerSettings(IgnoreApi = true)] -public class SetupController( +public partial class SetupController( ISetupToken setupToken, IMaintenanceModeNotConfigureService notConfigureService, IMemoryCache cache, @@ -208,7 +208,7 @@ public class SetupController( [BadRequestResponse] public ActionResult CreateAdmin([FromBody] CreateUserRequest user) { - if (user.Password.Length < 8 || !Regex.IsMatch(user.Password, "[A-Z]+") || !Regex.IsMatch(user.Password, "[!@#$%^&*]+")) + if (user.Password.Length < 8 || !PasswordExistUpperLetter().IsMatch(user.Password) || !PasswordExistSpecialSymbol().IsMatch(user.Password)) throw new ControllerArgumentException("The password must be at least 8 characters long and contain at least one uppercase letter and one special character."); if (!MailAddress.TryCreate(user.Email, out _)) @@ -348,4 +348,10 @@ public class SetupController( return true; } + + [GeneratedRegex("[A-Z]+")] + private static partial Regex PasswordExistUpperLetter(); + + [GeneratedRegex("[!@#$%^&*]+")] + private static partial Regex PasswordExistSpecialSymbol(); } \ No newline at end of file