namespace IOL.GreatOffice.Api.Endpoints.Internal.PasswordResetRequests;
///
public class FulfillResetRequestRoute : RouteBaseAsync.WithRequest.WithActionResult
{
private readonly PasswordResetService _passwordResetService;
///
public FulfillResetRequestRoute(PasswordResetService passwordResetService) {
_passwordResetService = passwordResetService;
}
///
/// Fulfill a password reset request.
///
///
///
///
[AllowAnonymous]
[HttpPost("~/_/password-reset-request/fulfill")]
public override async Task HandleAsync(FulfillResetRequestPayload request, CancellationToken cancellationToken = default) {
try {
var fulfilled = await _passwordResetService.FullFillRequestAsync(request.Id, request.NewPassword, cancellationToken);
return Ok(fulfilled);
} catch (Exception e) {
if (e is ForgotPasswordRequestNotFoundException or UserNotFoundException) {
return NotFound();
}
throw;
}
}
}