- Cleaned up whitespace in Directory.Build.props and Directory.Packages.props for consistency. - Reformatted project file references in PnvPanel.Api.csproj for better clarity. - Enhanced code readability in various endpoint files by adjusting line breaks and indentation. - Standardized method signatures and improved formatting in ResultExtensions and multiple endpoint classes for better maintainability.
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using PnvPanel.Application.Common.Interfaces;
|
|
using PnvPanel.Application.Common.Messaging;
|
|
using PnvPanel.Application.Common.Models;
|
|
using PnvPanel.Domain.Audit;
|
|
|
|
namespace PnvPanel.Application.Admin.Users;
|
|
|
|
public sealed class ResetUserPasswordCommandHandler(
|
|
IAppDbContext dbContext,
|
|
IIdentityService identityService,
|
|
ICurrentUser currentUser
|
|
) : ICommandHandler<ResetUserPasswordCommand, Result>
|
|
{
|
|
public async Task<Result> Handle(
|
|
ResetUserPasswordCommand command,
|
|
CancellationToken cancellationToken
|
|
)
|
|
{
|
|
var result = await identityService.ResetPasswordAsync(
|
|
command.UserId,
|
|
command.NewPassword,
|
|
cancellationToken
|
|
);
|
|
if (!result.IsSuccess)
|
|
return result;
|
|
|
|
dbContext.AuditLogs.Add(
|
|
AuditLog.Create(
|
|
currentUser.UserId,
|
|
"UserPasswordReset",
|
|
"User",
|
|
command.UserId.ToString(),
|
|
metadata: null,
|
|
AuditSource.Web
|
|
)
|
|
);
|
|
await dbContext.SaveChangesAsync(cancellationToken);
|
|
|
|
return Result.Success();
|
|
}
|
|
}
|