You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ombi/src/Ombi/Attributes/WizardActionFilter.cs

27 lines
813 B

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection;
using Ombi.Core.Settings;
using Ombi.Settings.Settings.Models;
using System.Threading.Tasks;
namespace Ombi.Attributes
{
public class WizardActionFilter : IAsyncActionFilter
{
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
var settingsService = context.HttpContext.RequestServices.GetRequiredService<ISettingsService<OmbiSettings>>();
var settings = await settingsService.GetSettingsAsync();
if (!settings.Wizard)
{
await next();
return;
}
context.Result = new UnauthorizedResult();
}
}
}