Refactor envelope rejection logic in EnvelopeController
Clarified and streamlined the handling of rejected envelopes: - Moved retrieval of rejecting receivers for clarity. - Signed out users when any rejecting receivers are present. - Improved determination of "external" users. - Updated condition for showing the EnvelopeRejected view. - Temporarily hardcoded ViewBag.IsExt with a TODO for future fix. - Removed redundant code for better maintainability.
This commit is contained in:
@@ -79,14 +79,16 @@ public class EnvelopeController : ViewControllerBase
|
|||||||
return this.ViewEnvelopeNotFound();
|
return this.ViewEnvelopeNotFound();
|
||||||
|
|
||||||
#region Rejected or Signed
|
#region Rejected or Signed
|
||||||
//check rejection
|
|
||||||
if (er.Envelope.IsReadAndSign())
|
|
||||||
{
|
|
||||||
var rejRcvrs = await _historyService.ReadRejectingReceivers(er.Envelope!.Id);
|
var rejRcvrs = await _historyService.ReadRejectingReceivers(er.Envelope!.Id);
|
||||||
if (rejRcvrs.Any())
|
if (rejRcvrs.Any())
|
||||||
{
|
{
|
||||||
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
||||||
ViewBag.IsExt = !rejRcvrs.Contains(er.Receiver); //external if the current user is not rejected
|
var isExt = !rejRcvrs.Where(rcv => rcv.Id == er.Receiver!.Id).Any(); //external if the current user is not rejected
|
||||||
|
|
||||||
|
if (er.Envelope.IsReadAndSign() || !isExt)
|
||||||
|
{
|
||||||
|
//TODO: Normally assigned to the isExt variable. However, since the relevant keys are not defined in the resx files, it was assigned false. Fix this.
|
||||||
|
ViewBag.IsExt = true;
|
||||||
return View("EnvelopeRejected", er);
|
return View("EnvelopeRejected", er);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,14 +168,17 @@ public class EnvelopeController : ViewControllerBase
|
|||||||
}
|
}
|
||||||
var er_secret = er_secret_res.Data;
|
var er_secret = er_secret_res.Data;
|
||||||
|
|
||||||
//check rejection if the envelope is read-and-sign
|
|
||||||
if (er_secret.Envelope.IsReadAndSign())
|
|
||||||
{
|
|
||||||
var rejRcvrs = await _historyService.ReadRejectingReceivers(er_secret.Envelope!.Id);
|
var rejRcvrs = await _historyService.ReadRejectingReceivers(er_secret.Envelope!.Id);
|
||||||
if (rejRcvrs.Any())
|
if (rejRcvrs.Any())
|
||||||
{
|
{
|
||||||
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
||||||
ViewBag.IsExt = !rejRcvrs.Contains(er_secret.Receiver); //external if the current user is not rejected
|
var isExt = !rejRcvrs.Where(rcv => rcv.Id == er_secret.Receiver!.Id).Any(); //external if the current user is not rejected
|
||||||
|
|
||||||
|
//check rejection if the envelope is read-and-sign or non-external (internal)
|
||||||
|
if (er_secret.Envelope.IsReadAndSign() || !isExt)
|
||||||
|
{
|
||||||
|
//TODO: Normally assigned to the isExt variable. However, since the relevant keys are not defined in the resx files, it was assigned false. Fix this.
|
||||||
|
ViewBag.IsExt = true;
|
||||||
return View("EnvelopeRejected", er_secret);
|
return View("EnvelopeRejected", er_secret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user