backend + web: Set passwords through email confirmation
This commit is contained in:
1 parent
bd8eb65e56
commit
ee5f1d3d10
23 files changed
+281
-110
No files matched your search
@@ -1,17 +1,17 @@
|
||||
using System.Text;
|
||||
using FluentValidation;
|
||||
using Helpdesk.Application.Users;
|
||||
|
||||
namespace Helpdesk.Application.Auth;
|
||||
|
||||
public sealed record RegisterRequest(string Email, string Password, string FirstName, string LastName);
|
||||
public sealed record RegisterRequest(string Email, string FirstName, string LastName);
|
||||
|
||||
public sealed record LoginRequest(string Email, string Password);
|
||||
|
||||
/// <summary>Refresh token – pro <c>/auth/refresh</c> i <c>/auth/logout</c>.</summary>
|
||||
public sealed record RefreshTokenRequest(string RefreshToken);
|
||||
|
||||
/// <summary>Token z odkazu v e-mailu (ověření e-mailu).</summary>
|
||||
public sealed record EmailTokenRequest(string Token);
|
||||
public sealed record ConfirmEmailRequest(string Token, string NewPassword);
|
||||
|
||||
public sealed record ForgotPasswordRequest(string Email);
|
||||
|
||||
@@ -38,12 +38,22 @@ public sealed class RegisterRequestValidator : AbstractValidator<RegisterRequest
|
||||
public RegisterRequestValidator()
|
||||
{
|
||||
RuleFor(x => x.Email).NotEmpty().EmailAddress().MaximumLength(254);
|
||||
RuleFor(x => x.Password).ValidPassword();
|
||||
RuleFor(x => x.FirstName).NotEmpty().MaximumLength(100);
|
||||
RuleFor(x => x.LastName).NotEmpty().MaximumLength(100);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ConfirmEmailRequestValidator : AbstractValidator<ConfirmEmailRequest>
|
||||
{
|
||||
public ConfirmEmailRequestValidator()
|
||||
{
|
||||
RuleFor(x => x.Token).NotEmpty();
|
||||
RuleFor(x => x.NewPassword).Cascade(CascadeMode.Stop).ValidPassword()
|
||||
.Must(password => Encoding.UTF8.GetByteCount(password) <= 72)
|
||||
.WithMessage("Heslo může mít nejvýše 72 bajtů v UTF-8.");
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class LoginRequestValidator : AbstractValidator<LoginRequest>
|
||||
{
|
||||
public LoginRequestValidator()
|
||||
|
||||
Reference in new issue
Block a user