Files
blazor-crm/Features/Profile/Password/PasswordEndpoint.cs
T
2026-07-21 13:59:38 +07:00

26 lines
1.0 KiB
C#

using Indotalent.ConfigBackEnd.Extensions;
using Indotalent.Features.Profile.Password.Cqrs;
using MediatR;
using Microsoft.AspNetCore.Authentication.JwtBearer;
namespace Indotalent.Features.Profile.Password;
public static class PasswordEndpoint
{
public static void MapPasswordEndpoints(this IEndpointRouteBuilder app)
{
var group = app.MapGroup("/profile-password").WithTags("Profile Password")
.RequireAuthorization(policy => policy.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
.RequireAuthenticatedUser());
group.MapPost("/update", async (UpdatePasswordRequest request, IMediator mediator) =>
{
var result = await mediator.Send(new UpdatePasswordCommand(request));
if (!result.Success)
return ((object?)null).ToApiResponse(result.Message ?? "Failed to update password", StatusCodes.Status400BadRequest);
return result.ToApiResponse("Password has been updated successfully");
})
.WithName("UpdateProfilePassword");
}
}