Add password reset functionality for admin users: implement ResetPassword endpoint, update AdminUserEndpoints to include password reset logic, and enhance user interface for password management. Update translations for new features and ensure proper error handling in the reset process.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
using LiteCqrs;
|
||||
using TeleWave.Application.Common.Models;
|
||||
|
||||
namespace TeleWave.Application.Admin.Users.ResetPassword;
|
||||
|
||||
/// <summary>Сброс пароля пользователя администратором (без текущего пароля).</summary>
|
||||
public sealed record ResetUserPasswordCommand(Guid UserId, string NewPassword) : ICommand<Result>;
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using LiteCqrs;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
using TeleWave.Application.Common.Models;
|
||||
|
||||
namespace TeleWave.Application.Admin.Users.ResetPassword;
|
||||
|
||||
public sealed class ResetUserPasswordCommandHandler(IIdentityService identityService)
|
||||
: ICommandHandler<ResetUserPasswordCommand, Result>
|
||||
{
|
||||
public Task<Result> Handle(
|
||||
ResetUserPasswordCommand command,
|
||||
CancellationToken cancellationToken
|
||||
) => identityService.ResetPasswordAsync(command.UserId, command.NewPassword, cancellationToken);
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
using FluentValidation;
|
||||
|
||||
namespace TeleWave.Application.Admin.Users.ResetPassword;
|
||||
|
||||
public sealed class ResetUserPasswordCommandValidator : AbstractValidator<ResetUserPasswordCommand>
|
||||
{
|
||||
public ResetUserPasswordCommandValidator()
|
||||
{
|
||||
// Длина — здесь; сложность (цифра/заглавная) проверяют валидаторы ASP.NET Identity при сбросе.
|
||||
RuleFor(x => x.UserId).NotEmpty();
|
||||
RuleFor(x => x.NewPassword).NotEmpty().MinimumLength(8);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user