feat(EnvelopeController): sign out user after envelope actions

- Added `HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme)`
  to `CreateOrUpdate` and `Reject` endpoints in `EnvelopeController`
- Ensures user session is cleared after completing or rejecting envelope actions
- Updated using directives to include `Microsoft.AspNetCore.Authentication`
  and `Microsoft.AspNetCore.Authentication.Cookies`
This commit is contained in:
tekh 2025-09-17 10:31:09 +02:00
parent 6691471276
commit 5d65f58a55

View File

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