backend + web: Add admin account lifecycle management
This commit is contained in:
1 parent
fcf7cd0596
commit
91d0c06c83
25 files changed
+1148
-97
No files matched your search
@@ -1,4 +1,6 @@
|
||||
using System.Text;
|
||||
using FluentValidation;
|
||||
using Helpdesk.Application.Auth;
|
||||
using Helpdesk.Domain;
|
||||
using Helpdesk.Domain.Users;
|
||||
|
||||
@@ -45,3 +47,29 @@ public sealed record AdminUserDto(
|
||||
public sealed record ChangeRoleRequest(string Role);
|
||||
|
||||
public sealed record SetActiveRequest(bool IsActive);
|
||||
|
||||
public sealed record AdminUserDetailsDto(int Id, string Email, string FirstName, string LastName, string? Phone,
|
||||
string Role, bool IsActive, bool EmailConfirmed, bool EmailNotificationsEnabled, bool? VerificationEmailSent = null)
|
||||
{
|
||||
public static AdminUserDetailsDto From(User user) => new(user.Id, user.Email, user.FirstName, user.LastName, user.Phone,
|
||||
user.Role.ToCode(), user.IsActive, user.EmailConfirmed, user.EmailNotificationsEnabled);
|
||||
}
|
||||
|
||||
public sealed record SaveAdminUserRequest(string Email, string FirstName, string LastName, string? Phone,
|
||||
string Role, bool IsActive, bool EmailConfirmed, bool EmailNotificationsEnabled, string? Password);
|
||||
|
||||
public sealed class SaveAdminUserRequestValidator : AbstractValidator<SaveAdminUserRequest>
|
||||
{
|
||||
public SaveAdminUserRequestValidator()
|
||||
{
|
||||
RuleFor(x => x.Email).NotEmpty().EmailAddress().MaximumLength(254);
|
||||
RuleFor(x => x.Role).NotEmpty();
|
||||
RuleFor(x => x.Password)
|
||||
.NotEmpty().MinimumLength(PasswordRules.MinLength).MaximumLength(PasswordRules.MaxLength)
|
||||
.Must(password => password is null || Encoding.UTF8.GetByteCount(password) <= 72)
|
||||
.WithMessage("Heslo může mít nejvýše 72 bajtů v UTF-8.")
|
||||
.When(x => x.Password is not null);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record BulkAdminUsersRequest(int[] UserIds, string Action, string? Role);
|
||||
Reference in new issue
Block a user