Files
vtuber-awards/Backend/Security/HttpContextSessionExtensions.cs
T

15 lines
484 B
C#

using Backend.Domain;
namespace Backend.Security;
public static class HttpContextSessionExtensions
{
private const string SessionItemKey = "__current_session";
public static void SetCurrentSession(this HttpContext context, UserSession session) =>
context.Items[SessionItemKey] = session;
public static UserSession? GetCurrentSession(this HttpContext context) =>
context.Items.TryGetValue(SessionItemKey, out var value) ? value as UserSession : null;
}