Allow nullable annotation param; validate for non-readonly
Make psPdfKitAnnotation optional in CreateOrUpdate. Add validation to require an annotation for non read-and-confirm envelopes, returning BadRequest if missing.
This commit is contained in:
@@ -44,7 +44,7 @@ public class AnnotationController : ControllerBase
|
|||||||
|
|
||||||
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> CreateOrUpdate([FromBody] PsPdfKitAnnotation psPdfKitAnnotation, CancellationToken cancel = default)
|
public async Task<IActionResult> CreateOrUpdate([FromBody] PsPdfKitAnnotation? psPdfKitAnnotation = null, CancellationToken cancel = default)
|
||||||
{
|
{
|
||||||
// get claims
|
// get claims
|
||||||
var signature = User.GetAuthReceiverSignature();
|
var signature = User.GetAuthReceiverSignature();
|
||||||
@@ -56,6 +56,12 @@ public class AnnotationController : ControllerBase
|
|||||||
return Unauthorized("User authentication is incomplete. Missing required claims for processing this request.");
|
return Unauthorized("User authentication is incomplete. Missing required claims for processing this request.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if non read-and-confirm envelope is signed without annotation
|
||||||
|
var er = await _mediator.ReadEnvelopeReceiverAsync(uuid, signature, cancel).ThrowIfNull(Exceptions.NotFound);
|
||||||
|
|
||||||
|
if (!er.Envelope!.ReadOnly && psPdfKitAnnotation is null)
|
||||||
|
return BadRequest();
|
||||||
|
|
||||||
// Again check if receiver has already signed
|
// Again check if receiver has already signed
|
||||||
if (await _mediator.IsSignedAsync(uuid, signature, cancel))
|
if (await _mediator.IsSignedAsync(uuid, signature, cancel))
|
||||||
return Problem(statusCode: 409);
|
return Problem(statusCode: 409);
|
||||||
|
|||||||
Reference in New Issue
Block a user