Endpunkt für die Ablehnung von Umschlägen hinzugefügt.

This commit is contained in:
Developer 02
2024-06-04 16:11:30 +02:00
parent 34b3c46720
commit 7697939d7e
5 changed files with 75 additions and 52 deletions

View File

@@ -6,39 +6,17 @@ namespace EnvelopeGenerator.Web.Controllers
{
public static class ControllerBaseExtensions
{
public static (string EnvelopeUuid, string ReceiverSignature)? GetAuthenticatedEnvelopeDetails(this ControllerBase controller)
{
if(controller?.User?.Identity?.IsAuthenticated ?? false)
{
var envelopeUuid = controller.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
var receiverSignature = controller.User.FindFirst(ClaimTypes.Hash)?.Value;
if (!string.IsNullOrEmpty(envelopeUuid) && !string.IsNullOrEmpty(receiverSignature))
return (EnvelopeUuid: envelopeUuid, ReceiverSignature: receiverSignature);
}
return null;
}
public static string? GetClaimValue(this ControllerBase controller, string claimType) => controller.User.FindFirstValue(claimType);
public static string? GetAuthenticatedEnvelopeUuid(this ControllerBase controller)
{
if (controller?.User?.Identity?.IsAuthenticated ?? false)
{
var envelopeUuid = controller.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
if (!string.IsNullOrEmpty(envelopeUuid))
return envelopeUuid;
}
return null;
}
public static string? GetAuthEnvelopeUuid(this ControllerBase controller) => controller.User.FindFirstValue(ClaimTypes.NameIdentifier);
public static string? GetAuthenticatedReceiverSignature(this ControllerBase controller)
{
if (controller?.User?.Identity?.IsAuthenticated ?? false)
{
var receiverSignature = controller.User.FindFirst(ClaimTypes.Hash)?.Value;
if (!string.IsNullOrEmpty(receiverSignature))
return receiverSignature;
}
return null;
}
public static string? GetAuthReceiverSignature(this ControllerBase controller) => controller.User.FindFirstValue(ClaimTypes.Hash);
public static string? GetAuthReceiverName(this ControllerBase controller) => controller.User.FindFirstValue(ClaimTypes.Name);
public static string? GetAuthReceiverMail(this ControllerBase controller) => controller.User.FindFirstValue(ClaimTypes.Email);
public static string? GetAuthEnvelopeTitle(this ControllerBase controller) => controller.User.FindFirstValue(EnvelopeClaimTypes.Title);
//TODO: integrate localizer for ready-to-use views
public static ViewResult ViewError(this Controller controller, ErrorViewModel errorViewModel) => controller.View("_Error", errorViewModel);