diff options
Diffstat (limited to 'plugins/VNLib.Plugins.Essentials.Accounts/src/Validators')
-rw-r--r-- | plugins/VNLib.Plugins.Essentials.Accounts/src/Validators/LoginMessageValidation.cs | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/plugins/VNLib.Plugins.Essentials.Accounts/src/Validators/LoginMessageValidation.cs b/plugins/VNLib.Plugins.Essentials.Accounts/src/Validators/LoginMessageValidation.cs index dbb778f..4cdf51b 100644 --- a/plugins/VNLib.Plugins.Essentials.Accounts/src/Validators/LoginMessageValidation.cs +++ b/plugins/VNLib.Plugins.Essentials.Accounts/src/Validators/LoginMessageValidation.cs @@ -31,18 +31,10 @@ using VNLib.Plugins.Extensions.Validation; namespace VNLib.Plugins.Essentials.Accounts.Validators { - internal class LoginMessageValidation : AbstractValidator<LoginMessage> + internal class LoginMessageValidation : ClientSecurityMessageValidator<LoginMessage> { - public LoginMessageValidation() + public LoginMessageValidation() :base() { - RuleFor(static t => t.ClientId) - .Length(min: 10, max: 100) - .WithMessage(errorMessage: "Your browser is not sending required security information"); - - RuleFor(static t => t.ClientPublicKey) - .NotEmpty() - .Length(min: 50, max: 1000) - .WithMessage(errorMessage: "Your browser is not sending required security information"); /* Rules for user-input on passwords, set max length to avoid DOS */ RuleFor(static t => t.Password) @@ -67,4 +59,19 @@ namespace VNLib.Plugins.Essentials.Accounts.Validators .WithMessage(errorMessage: "Please check your system clock"); } } + + internal class ClientSecurityMessageValidator<T> : AbstractValidator<T> where T: IClientSecInfo + { + public ClientSecurityMessageValidator() + { + RuleFor(static t => t.ClientId) + .Length(min: 10, max: 100) + .WithMessage(errorMessage: "Your browser is not sending required security information"); + + RuleFor(static t => t.PublicKey) + .NotEmpty() + .Length(min: 50, max: 1000) + .WithMessage(errorMessage: "Your browser is not sending required security information"); + } + } } |