Add sender endpoint for envelope-level PDF signing
This commit is contained in:
@@ -18,6 +18,23 @@ namespace EnvelopeGenerator.Server.Controllers;
|
||||
[Route("api/[controller]")]
|
||||
public class PdfSignatureController(IPdfDigitalSignatureService SignatureService, IMediator Mediator) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Authorize(AuthenticationSchemes = AuthScheme.Sender)]
|
||||
public async Task<IActionResult> SignDocument(SignPdfByEnvelopeCommand command, CancellationToken cancel)
|
||||
{
|
||||
var senderId = User.SenderId();
|
||||
var result = await Mediator.Send(command.Authorized(senderId), cancel);
|
||||
result.Position = 0;
|
||||
var fileName = Path.GetFileNameWithoutExtension($"e{command.Id.ToString() ?? command.Uuid}_s{senderId}");
|
||||
return File(result, "application/pdf", $"{fileName}_signed.pdf");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the document for the specified envelope key.
|
||||
/// </summary>
|
||||
@@ -26,7 +43,7 @@ public class PdfSignatureController(IPdfDigitalSignatureService SignatureService
|
||||
/// <returns></returns>
|
||||
[Authorize(Policy = AuthPolicy.Receiver)]
|
||||
[HttpPost("{envelopeKey}")]
|
||||
public async Task<IActionResult> SignDocument(string envelopeKey, CancellationToken cancel)
|
||||
public async Task<IActionResult> SignDocumentByReceiver(string envelopeKey, CancellationToken cancel)
|
||||
{
|
||||
int envelopeId = User.EnvelopeId();
|
||||
int receiverId = User.ReceiverId();
|
||||
@@ -38,8 +55,8 @@ public class PdfSignatureController(IPdfDigitalSignatureService SignatureService
|
||||
}, cancel);
|
||||
|
||||
senderDoc.Position = 0;
|
||||
var fileName = Path.GetFileNameWithoutExtension(envelopeKey);
|
||||
return File(senderDoc, "application/pdf", $"{fileName}-signed.pdf");
|
||||
var fileName = Path.GetFileNameWithoutExtension($"e{envelopeId}_r{receiverId}");
|
||||
return File(senderDoc, "application/pdf", $"{fileName}_signed.pdf");
|
||||
}
|
||||
|
||||
#region Test Endpoints
|
||||
@@ -76,6 +93,7 @@ public class PdfSignatureController(IPdfDigitalSignatureService SignatureService
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
[AllowAnonymous]
|
||||
[HttpPost("sign")]
|
||||
[Consumes("multipart/form-data")]
|
||||
@@ -100,6 +118,7 @@ public class PdfSignatureController(IPdfDigitalSignatureService SignatureService
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
[AllowAnonymous]
|
||||
[HttpPost("is-signed")]
|
||||
[Consumes("multipart/form-data")]
|
||||
|
||||
Reference in New Issue
Block a user