Fixed missing uploads authorization check

This commit is contained in:
2025-11-30 20:34:19 +01:00
parent 428ebc2e3f
commit 068d7c4b3e

View File

@@ -1,3 +1,4 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Localization;
using Microsoft.EntityFrameworkCore;
@@ -94,7 +95,19 @@ app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.MapStaticAssets();
app.Use(async (context, next) =>
{
if (context.Request.Path.StartsWithSegments("/uploads")
&& !(context.User.Identity?.IsAuthenticated ?? false))
{
context.Response.StatusCode = 401;
return;
}
await next();
});
app.UseStaticFiles();
app.MapControllerRoute(
name: "default",