added auth with a simple UI

This commit is contained in:
2026-03-09 23:29:04 +01:00
parent c8347ac96b
commit 82ac241129
123 changed files with 3419 additions and 93 deletions

View File

@@ -0,0 +1,23 @@
using OED.Api.Core.Interfaces.Services;
namespace OED.Api.Infrastructure.Auth;
// Runs on every request — reads the session cookie and stamps CharacterId onto HttpContext.Items
public class SessionMiddleware(RequestDelegate next)
{
public async Task InvokeAsync(HttpContext context, ISessionService sessionService)
{
if (context.Request.Cookies.TryGetValue("session", out var sessionId))
{
var session = await sessionService.GetAsync(sessionId);
if (session is not null)
{
context.Items["CharacterId"] = session.CharacterId;
context.Items["CharacterName"] = session.CharacterName;
context.Items["Session"] = session;
}
}
await next(context);
}
}