summaryrefslogtreecommitdiff
path: root/Program.cs
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2023-09-17 22:51:50 +1000
committerJake Mannens <jakem_5@hotmail.com>2026-01-14 20:30:37 +1100
commita440be4df759c7d317c1574ce1132fab807494f2 (patch)
tree157bc8246beabf1cb361ff9ec2416a2244a2843a /Program.cs
parentee17b95e1deb121636eaaebad8a0351f28ad704a (diff)
Consolidated user session state and made it persistent across all scopes pertaining to a session
Diffstat (limited to 'Program.cs')
-rw-r--r--Program.cs3
1 files changed, 3 insertions, 0 deletions
diff --git a/Program.cs b/Program.cs
index e78f0d4..79fe8fa 100644
--- a/Program.cs
+++ b/Program.cs
@@ -8,6 +8,7 @@ namespace HyperBooru;
public class Program {
public static void Main(string[] args) {
var builder = WebApplication.CreateBuilder(args);
+ builder.Services.AddSession();
builder.Services.AddHttpContextAccessor();
builder.Services.AddAuthentication(
CookieAuthenticationDefaults.AuthenticationScheme).AddCookie();
@@ -24,6 +25,7 @@ public class Program {
builder.Services.AddScoped<ISearchService, SearchService>();
builder.Services.AddScoped<ITagService, TagService>();
builder.Services.AddScoped<IMediaService, MediaService>();
+ builder.Services.AddSingleton<IGlobalUserService, GlobalUserService>();
builder.Services.AddScoped<IUserService, UserService>();
builder.Services.AddHostedService<OcrService>();
@@ -34,6 +36,7 @@ public class Program {
using var db = scope.ServiceProvider.GetRequiredService<HBContext>();
db.Database.Migrate();
+ app.UseSession();
app.UseHsts();
app.UseHttpsRedirection();
app.UseStaticFiles();