diff --git a/EnvelopeGenerator.Web/Controllers/EnvelopeController.cs b/EnvelopeGenerator.Web/Controllers/EnvelopeController.cs index 0d78ce19..6af3cb93 100644 --- a/EnvelopeGenerator.Web/Controllers/EnvelopeController.cs +++ b/EnvelopeGenerator.Web/Controllers/EnvelopeController.cs @@ -7,6 +7,8 @@ using EnvelopeGenerator.Application.EnvelopeReceivers.Queries; using EnvelopeGenerator.Domain.Constants; using EnvelopeGenerator.Web.Extensions; using MediatR; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Dynamic; @@ -65,6 +67,8 @@ public class EnvelopeController : ControllerBase await _mediator.Publish(docSignedNotification, cancel); + await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + return Ok(); } @@ -91,13 +95,17 @@ public class EnvelopeController : ControllerBase return Unauthorized("you are not authirized"); } - return await _histService.RecordAsync(envRcvRes.Data.EnvelopeId, userReference: mail, EnvelopeStatus.DocumentRejected, comment: reason).ThenAsync( - Success: id => NoContent(), - Fail: IActionResult (mssg, ntc) => - { - _logger.LogEnvelopeError(uuid: uuid, signature: signature, message: "Unexpected error happend in api/envelope/reject"); - _logger.LogNotice(ntc); - return StatusCode(500, mssg); - }); + var histRes = await _histService.RecordAsync(envRcvRes.Data.EnvelopeId, userReference: mail, EnvelopeStatus.DocumentRejected, comment: reason); + if (histRes.IsSuccess) + { + await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + return NoContent(); + } + else + { + _logger.LogEnvelopeError(uuid: uuid, signature: signature, message: "Unexpected error happend in api/envelope/reject"); + _logger.LogNotice(histRes.Notices); + return StatusCode(500, histRes.Messages); + } } } \ No newline at end of file