mirror of
https://github.com/spacebarchat/server.git
synced 2026-09-18 03:36:19 +00:00
Fix admin api service resolution stuff
This commit is contained in:
@@ -7,7 +7,6 @@ namespace Spacebar.AdminApi.Middleware;
|
||||
|
||||
public class AuthenticationMiddleware(
|
||||
ILogger<AuthenticationMiddleware> logger,
|
||||
SpacebarAspNetAuthenticationService authService,
|
||||
SpacebarAuthenticationConfiguration config,
|
||||
RequestDelegate next) {
|
||||
public async Task InvokeAsync(HttpContext context, IServiceProvider sp) {
|
||||
@@ -16,6 +15,9 @@ public class AuthenticationMiddleware(
|
||||
return;
|
||||
}
|
||||
|
||||
await using var spScope = sp.CreateAsyncScope();
|
||||
var authService = spScope.ServiceProvider.GetRequiredService<SpacebarAspNetAuthenticationService>();
|
||||
|
||||
TokenValidationResult? res = null;
|
||||
try {
|
||||
await authService.ValidateTokenAsync(context.Request);
|
||||
|
||||
@@ -30,7 +30,7 @@ builder.Services.AddDbContextPool<SpacebarDbContext>(options => {
|
||||
.UseNpgsql(builder.Configuration.GetConnectionString("Spacebar"))
|
||||
.EnableDetailedErrors();
|
||||
});
|
||||
builder.Services.AddScoped<SpacebarAuthenticationConfiguration>();
|
||||
builder.Services.AddSingleton<SpacebarAuthenticationConfiguration>();
|
||||
builder.Services.AddScoped<SpacebarAuthenticationService>();
|
||||
builder.Services.AddScoped<SpacebarAspNetAuthenticationService>();
|
||||
// builder.Services.AddSingleton<RabbitMQConfiguration>();
|
||||
|
||||
Reference in New Issue
Block a user