09-01-2024
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using EnvelopeGenerator.Web.Models;
|
||||
using EnvelopeGenerator.Web.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Controllers
|
||||
@@ -10,7 +11,7 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
{
|
||||
private readonly EnvelopeService _envelopeService;
|
||||
|
||||
public HomeController(DatabaseService database, LoggingService logging, EnvelopeService envelopeService): base(database, logging)
|
||||
public HomeController(DatabaseService databaseService, LoggingService loggingService, EnvelopeService envelopeService): base(databaseService, loggingService)
|
||||
{
|
||||
_envelopeService = envelopeService;
|
||||
}
|
||||
@@ -28,12 +29,83 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
[HttpGet]
|
||||
[Route("/EnvelopeKey/{EnvelopeReceiverId}")]
|
||||
public IActionResult ShowEnvelope()
|
||||
{
|
||||
string envelopeKey = (string)HttpContext.Request.RouteValues["EnvelopeReceiverId"];
|
||||
|
||||
EnvelopeResponse response = _envelopeService.LoadEnvelope(envelopeKey);
|
||||
string accessCode = response.Receiver.AccessCode;
|
||||
|
||||
if (!String.IsNullOrEmpty(accessCode))
|
||||
{
|
||||
bool accessCodeAlreadyRequested = database.Models.receiverModel.AccessCodeAlreadyRequested(response.Receiver.Email, response.Envelope.Id);
|
||||
|
||||
if (!accessCodeAlreadyRequested)
|
||||
{
|
||||
// Send email with password
|
||||
bool actionResult = database.Services.actionService.RequestAccessCode(response.Envelope, response.Receiver);
|
||||
bool result = database.Services.emailService.SendDocumentAccessCodeReceivedEmail(response.Envelope, response.Receiver);
|
||||
}
|
||||
|
||||
return Redirect($"/EnvelopeKey/{envelopeKey}/Locked");
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewData["EnvelopeKey"] = envelopeKey;
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("/EnvelopeKey/{EnvelopeReceiverId}/Locked")]
|
||||
public IActionResult ShowEnvelopePost()
|
||||
{
|
||||
string envelopeKey = (string)HttpContext.Request.RouteValues["EnvelopeReceiverId"];
|
||||
|
||||
StringValues accessCodeFromForm = HttpContext.Request.Form["access_code"];
|
||||
|
||||
if (accessCodeFromForm.Count == 0)
|
||||
{
|
||||
return Redirect($"/EnvelopeKey/{envelopeKey}/Locked");
|
||||
}
|
||||
|
||||
if (accessCodeFromForm.Count > 1)
|
||||
{
|
||||
return Redirect($"/EnvelopeKey/{envelopeKey}/Locked");
|
||||
}
|
||||
|
||||
EnvelopeResponse response = _envelopeService.LoadEnvelope(envelopeKey);
|
||||
string accessCode = response.Receiver.AccessCode;
|
||||
|
||||
if (string.IsNullOrEmpty(accessCodeFromForm[0]))
|
||||
{
|
||||
return Redirect($"/EnvelopeKey/{envelopeKey}/Locked");
|
||||
}
|
||||
|
||||
if (accessCode.Equals(accessCodeFromForm[0], StringComparison.Ordinal))
|
||||
{
|
||||
bool actionResult = database.Services.actionService.EnterCorrectAccessCode(response.Envelope, response.Receiver);
|
||||
ViewData["EnvelopeKey"] = envelopeKey;
|
||||
return View("ShowEnvelope");
|
||||
}
|
||||
else
|
||||
{
|
||||
bool actionResult = database.Services.actionService.EnterIncorrectAccessCode(response.Envelope, response.Receiver);
|
||||
return Redirect($"/EnvelopeKey/{envelopeKey}/Locked");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("/EnvelopeKey/{EnvelopeReceiverId}/Locked")]
|
||||
public IActionResult EnvelopeLocked()
|
||||
{
|
||||
ViewData["EnvelopeKey"] = HttpContext.Request.RouteValues["EnvelopeReceiverId"];
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpGet]
|
||||
[Route("/EnvelopeKey/{EnvelopeReceiverId}/Success")]
|
||||
public IActionResult EnvelopeSigned()
|
||||
|
||||
@@ -12,10 +12,12 @@ namespace EnvelopeGenerator.Web.Services
|
||||
public class ServiceContainer
|
||||
{
|
||||
public ActionService actionService;
|
||||
public EmailService emailService;
|
||||
|
||||
public ServiceContainer(State state)
|
||||
{
|
||||
actionService = new(state);
|
||||
emailService = new(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
32
EnvelopeGenerator.Web/Views/Home/EnvelopeLocked.cshtml
Normal file
32
EnvelopeGenerator.Web/Views/Home/EnvelopeLocked.cshtml
Normal file
@@ -0,0 +1,32 @@
|
||||
@{
|
||||
ViewData["Title"] = "Dokument geschützt";
|
||||
}
|
||||
|
||||
<div id="page-locked" class="container p-5">
|
||||
<header class="text-center">
|
||||
<div class="icon bg-warning text-black">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="72" height="72" fill="currentColor" class="bi bi-shield-lock" viewBox="0 0 16 16">
|
||||
<path d="M5.338 1.59a61 61 0 0 0-2.837.856.48.48 0 0 0-.328.39c-.554 4.157.726 7.19 2.253 9.188a10.7 10.7 0 0 0 2.287 2.233c.346.244.652.42.893.533q.18.085.293.118a1 1 0 0 0 .101.025 1 1 0 0 0 .1-.025q.114-.034.294-.118c.24-.113.547-.29.893-.533a10.7 10.7 0 0 0 2.287-2.233c1.527-1.997 2.807-5.031 2.253-9.188a.48.48 0 0 0-.328-.39c-.651-.213-1.75-.56-2.837-.855C9.552 1.29 8.531 1.067 8 1.067c-.53 0-1.552.223-2.662.524zM5.072.56C6.157.265 7.31 0 8 0s1.843.265 2.928.56c1.11.3 2.229.655 2.887.87a1.54 1.54 0 0 1 1.044 1.262c.596 4.477-.787 7.795-2.465 9.99a11.8 11.8 0 0 1-2.517 2.453 7 7 0 0 1-1.048.625c-.28.132-.581.24-.829.24s-.548-.108-.829-.24a7 7 0 0 1-1.048-.625 11.8 11.8 0 0 1-2.517-2.453C1.928 10.487.545 7.169 1.141 2.692A1.54 1.54 0 0 1 2.185 1.43 63 63 0 0 1 5.072.56" />
|
||||
<path d="M9.5 6.5a1.5 1.5 0 0 1-1 1.415l.385 1.99a.5.5 0 0 1-.491.595h-.788a.5.5 0 0 1-.49-.595l.384-1.99a1.5 1.5 0 1 1 2-1.415" />
|
||||
</svg>
|
||||
</div>
|
||||
<h1>Dokument erfordert ein Passwort</h1>
|
||||
</header>
|
||||
|
||||
<section class="text-center">
|
||||
<p>Wir haben Ihnen das Passwort an die hinterlegte Email Adresse gesendet.</p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<form id="form-access-code" method="post">
|
||||
<div class="input">
|
||||
<label class="visually-hidden" for="access_code">PAsswort</label>
|
||||
<input type="password" class="form-control" name="access_code" placeholder="Passwort" required="required">
|
||||
</div>
|
||||
|
||||
<div class="button">
|
||||
<button type="submit" class="btn btn-primary">Öffnen</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
@@ -1,4 +1,5 @@
|
||||
@using EnvelopeGenerator.Common;
|
||||
@using static EnvelopeGenerator.Common.Constants;
|
||||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
@@ -13,12 +14,20 @@
|
||||
|
||||
<div class="container">
|
||||
<section>
|
||||
<ul>
|
||||
@foreach (Envelope envelope in @Model)
|
||||
{
|
||||
<li><a href="/EnvelopeKey/@encodeEnvelopeKey(envelope)">@envelope.Title</a></li>
|
||||
}
|
||||
</ul>
|
||||
@foreach (IGrouping<EnvelopeStatus, Envelope> group in ((List<Envelope>)@Model).GroupBy(item => item.Status).OrderBy(item => (int)item.Key))
|
||||
{
|
||||
<section>
|
||||
<h2>@group.Key.ToString()</h2>
|
||||
|
||||
<ul>
|
||||
@foreach (Envelope envelope in @group)
|
||||
{
|
||||
<li><a href="/EnvelopeKey/@encodeEnvelopeKey(envelope)">@envelope.Title</a></li>
|
||||
}
|
||||
</ul>
|
||||
<hr />
|
||||
</section>
|
||||
}
|
||||
</section>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -50,3 +50,25 @@
|
||||
padding: 15px;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
/* Locked Page */
|
||||
|
||||
#page-locked header .icon {
|
||||
display: inline-block;
|
||||
border-radius: 10px;
|
||||
padding: 15px;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
#form-access-code {
|
||||
max-width: 30rem;
|
||||
margin: 2rem auto;
|
||||
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
#form-access-code > .input {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user