IW4M-Admin/WebfrontCore/Controllers/BaseController.cs

30 lines
1.0 KiB
C#
Raw Normal View History

2018-03-06 02:22:19 -05:00
using IW4MAdmin;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using SharedLibrary;
using SharedLibrary.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WebfrontCore.Controllers
{
public class BaseController : Controller
{
protected ApplicationManager Manager;
protected bool Authorized { get; private set; }
public override void OnActionExecuting(ActionExecutingContext context)
{
Manager = IW4MAdmin.Program.ServerManager;
2018-03-09 03:01:12 -05:00
Authorized = context.HttpContext.Connection.RemoteIpAddress.ToString() == "127.0.0.1" ||
Manager.AdministratorIPs.Contains(context.HttpContext.Connection.RemoteIpAddress.ToString().ConvertToIP());
ViewBag.Authorized = Authorized;
ViewBag.Url = Startup.Configuration["Web:Address"];
ViewBag.DiscordLink = Manager.GetApplicationSettings().DiscordInviteCode;
2018-03-06 02:22:19 -05:00
base.OnActionExecuting(context);
}
}
}