feat(HomeController): TryShowEnvelope-Methode erstellt, um die Generierung der Show-Envelope-Ansicht zu zentrieren
- TryShowEnvelope-Methode zum EnvelopeLocked-Endpunkt hinzugefügt, um den Umschlag anzuzeigen, wenn der Benutzer bereits autorisiert wurde.
This commit is contained in:
parent
57ea9e01f8
commit
1b1edca23c
@ -134,18 +134,23 @@ public class HomeController : ViewControllerBase
|
||||
ViewData["UserCulture"] = _cultures[UserLanguage];
|
||||
|
||||
return await _envRcvService.ReadByEnvelopeReceiverIdAsync(envelopeReceiverId: envelopeReceiverId).ThenAsync(
|
||||
Success: er => View()
|
||||
SuccessAsync: async er => {
|
||||
if (User.IsInRole(ReceiverRole.FullyAuth))
|
||||
return await TryShowEnvelope(envelopeReceiverId, er);
|
||||
else
|
||||
return View()
|
||||
.WithData("EnvelopeKey", envelopeReceiverId)
|
||||
.WithData("TFAEnabled", er.Envelope!.TFAEnabled)
|
||||
.WithData("HasPhoneNumber", er.HasPhoneNumber)
|
||||
.WithData("SenderEmail", er.Envelope.User!.Email)
|
||||
.WithData("EnvelopeTitle", er.Envelope.Title),
|
||||
Fail: IActionResult (messages, notices) =>
|
||||
{
|
||||
_logger.LogNotice(notices);
|
||||
Response.StatusCode = StatusCodes.Status401Unauthorized;
|
||||
return this.ViewEnvelopeNotFound();
|
||||
});
|
||||
.WithData("EnvelopeTitle", er.Envelope.Title);
|
||||
},
|
||||
Fail: IActionResult (messages, notices) =>
|
||||
{
|
||||
_logger.LogNotice(notices);
|
||||
Response.StatusCode = StatusCodes.Status401Unauthorized;
|
||||
return this.ViewEnvelopeNotFound();
|
||||
});
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@ -154,6 +159,63 @@ public class HomeController : ViewControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<IActionResult> TryShowEnvelope(string envelopeReceiverId, EnvelopeReceiverDto er)
|
||||
{
|
||||
try
|
||||
{
|
||||
ViewData["UserCulture"] = _cultures[UserLanguage];
|
||||
ViewData["EnvelopeKey"] = envelopeReceiverId;
|
||||
|
||||
envelopeReceiverId = _sanitizer.Sanitize(envelopeReceiverId);
|
||||
(string? uuid, string? signature) = envelopeReceiverId.DecodeEnvelopeReceiverId();
|
||||
|
||||
if (uuid is null || signature is null)
|
||||
{
|
||||
_logger.LogEnvelopeError(uuid: uuid, signature: signature, message: _localizer[WebKey.WrongEnvelopeReceiverId]);
|
||||
return Unauthorized();
|
||||
}
|
||||
|
||||
_logger.LogInformation("Envelope UUID: [{uuid}]\nReceiver Signature: [{signature}]", uuid, signature);
|
||||
|
||||
//check access code
|
||||
EnvelopeResponse response = await envelopeOldService.LoadEnvelope(envelopeReceiverId);
|
||||
|
||||
//check rejection
|
||||
var rejRcvrs = await _historyService.ReadRejectingReceivers(er.Envelope!.Id);
|
||||
if (rejRcvrs.Any())
|
||||
{
|
||||
ViewBag.IsExt = !rejRcvrs.Contains(er.Receiver); //external if the current user is not rejected
|
||||
return View("EnvelopeRejected", er);
|
||||
}
|
||||
|
||||
//check if it has already signed
|
||||
if (await _historyService.IsSigned(envelopeId: er.Envelope!.Id, userReference: er.Receiver!.EmailAddress))
|
||||
return View("EnvelopeSigned");
|
||||
|
||||
if (er.Envelope.Documents?.FirstOrDefault() is EnvelopeDocumentDto doc && doc.ByteData is not null)
|
||||
{
|
||||
ViewData["DocumentBytes"] = doc.ByteData;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogEnvelopeError(envelopeReceiverId: envelopeReceiverId, message: "No document byte-data was found in ENVELOPE_DOCUMENT table.");
|
||||
return this.ViewDocumentNotFound();
|
||||
}
|
||||
|
||||
await HttpContext.SignInEnvelopeAsync(er, ReceiverRole.FullyAuth);
|
||||
|
||||
//add PSPDFKit licence key
|
||||
ViewData["PSPDFKitLicenseKey"] = _configuration["PSPDFKitLicenseKey"];
|
||||
|
||||
return View("ShowEnvelope", er);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogEnvelopeError(envelopeReceiverId: envelopeReceiverId, exception: ex);
|
||||
return this.ViewInnerServiceError();
|
||||
}
|
||||
}
|
||||
|
||||
#region TFA Views
|
||||
[NonAction]
|
||||
private async Task<IActionResult> TFAViewAsync(bool viaSms, EnvelopeReceiverSecretDto er_secret, string envelopeReceiverId)
|
||||
@ -317,46 +379,18 @@ public class HomeController : ViewControllerBase
|
||||
.WithData("EnvelopeTitle", er_secret.Envelope.Title)
|
||||
.WithData("ErrorMessage", _localizer[WebKey.WrongAccessCode].Value);
|
||||
}
|
||||
|
||||
await HttpContext.SignInEnvelopeAsync(er_secret, ReceiverRole.FullyAuth);
|
||||
|
||||
//continue the process without important data to minimize security errors.
|
||||
EnvelopeReceiverDto er = er_secret;
|
||||
|
||||
//check rejection
|
||||
var rejRcvrs = await _historyService.ReadRejectingReceivers(er.Envelope!.Id);
|
||||
if(rejRcvrs.Any())
|
||||
{
|
||||
ViewBag.IsExt = !rejRcvrs.Contains(er.Receiver); //external if the current user is not rejected
|
||||
return View("EnvelopeRejected", er);
|
||||
}
|
||||
|
||||
//check if it has already signed
|
||||
if (await _historyService.IsSigned(envelopeId: er.Envelope!.Id, userReference: er.Receiver!.EmailAddress))
|
||||
return View("EnvelopeSigned");
|
||||
|
||||
if (er.Envelope.Documents?.FirstOrDefault() is EnvelopeDocumentDto doc && doc.ByteData is not null)
|
||||
{
|
||||
ViewData["DocumentBytes"] = doc.ByteData;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogEnvelopeError(envelopeReceiverId: envelopeReceiverId, message: "No document byte-data was found in ENVELOPE_DOCUMENT table.");
|
||||
return this.ViewDocumentNotFound();
|
||||
}
|
||||
|
||||
await HttpContext.SignInEnvelopeAsync(er, ReceiverRole.FullyAuth);
|
||||
|
||||
//add PSPDFKit licence key
|
||||
ViewData["PSPDFKitLicenseKey"] = _configuration["PSPDFKitLicenseKey"];
|
||||
|
||||
return View("ShowEnvelope", er);
|
||||
return await TryShowEnvelope(envelopeReceiverId, er_secret);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogEnvelopeError(envelopeReceiverId: envelopeReceiverId, exception: ex);
|
||||
return this.ViewInnerServiceError();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||
[HttpGet("EnvelopeKey/{envelopeReceiverId}/Success")]
|
||||
public async Task<IActionResult> EnvelopeSigned(string envelopeReceiverId)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user