email and password change panels added
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using FluentValidation;
|
||||
using WatchIt.Common.Model.Accounts;
|
||||
using WatchIt.Database;
|
||||
|
||||
namespace WatchIt.WebAPI.Validators.Accounts;
|
||||
|
||||
public class AccountEmailRequestValidator : AbstractValidator<AccountEmailRequest>
|
||||
{
|
||||
public AccountEmailRequestValidator(DatabaseContext database)
|
||||
{
|
||||
RuleFor(x => x.NewEmail).EmailAddress()
|
||||
.CannotBeIn(database.Accounts, x => x.Email)
|
||||
.WithMessage("Email was already used");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using FluentValidation;
|
||||
using WatchIt.Common.Model.Accounts;
|
||||
using WatchIt.Database;
|
||||
|
||||
namespace WatchIt.WebAPI.Validators.Accounts;
|
||||
|
||||
public class AccountPasswordRequestValidator : AbstractValidator<AccountPasswordRequest>
|
||||
{
|
||||
public AccountPasswordRequestValidator(DatabaseContext database)
|
||||
{
|
||||
RuleFor(x => x.NewPassword).MinimumLength(8)
|
||||
.Must(x => x.Any(char.IsUpper)).WithMessage("Password must contain at least one uppercase letter.")
|
||||
.Must(x => x.Any(char.IsLower)).WithMessage("Password must contain at least one lowercase letter.")
|
||||
.Must(x => x.Any(char.IsDigit)).WithMessage("Password must contain at least one digit.")
|
||||
.Equal(x => x.NewPasswordConfirmation);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user