Files
monorepo/LCU.API.Internal.OnlineLoanApp/Landmark.OLA.Application/Common/Security/RenewAuthenticatedSessionMiddleware.cs
T
2026-03-11 11:18:25 -05:00

34 lines
1.0 KiB
C#

using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Serilog;
using OnlineBankingAuth.Tokens;
namespace Landmark.OLA.Application.Common.Security
{
public class RenewAuthenticatedSessionMiddleware
{
private readonly RequestDelegate _next;
public RenewAuthenticatedSessionMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext context, ITokenService tokenService)
{
await _next(context);
try
{
CookieService.SetAuthenticationCookie(context.Response.Cookies, tokenService.RenewOnlineBankingJWT(context));
CookieService.SetAuthorizationCookie(context.Response.Cookies, tokenService.RenewAuthorization(context));
}
catch(Exception ex)
{
Log.Fatal("Error renewing cookied", ex);
// Could not refresh token :-( no biggie?
}
}
}
}