Add hangfire

This commit is contained in:
Michał Zieliński
2025-10-12 18:28:14 +02:00
parent de5b8fbe16
commit b24aaab679
6 changed files with 152 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
using Hangfire.Dashboard;
namespace BimAI.API.Services;
public class HangfireAuthorizationFilter: IDashboardAsyncAuthorizationFilter
{
public Task<bool> AuthorizeAsync(DashboardContext context)
{
var httpContext = context.GetHttpContext();
var env = httpContext.RequestServices.GetService<IWebHostEnvironment>();
if (env.IsDevelopment())
{
return Task.FromResult(true);
}
var isAuthenticated = httpContext.User.Identity?.IsAuthenticated ?? false;
return Task.FromResult(isAuthenticated);
}
}