1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

add support for plugin generated pages (interactions). add disallow vpn command

This commit is contained in:
RaidMax
2022-10-17 09:17:43 -05:00
parent a71a5d7f3b
commit 450c8a45da
17 changed files with 311 additions and 45 deletions

View File

@ -19,6 +19,7 @@ namespace SharedLibraryCore
{
public class BaseController : Controller
{
protected readonly IInteractionRegistration InteractionRegistration;
protected readonly IAlertManager AlertManager;
/// <summary>
@ -41,6 +42,7 @@ namespace SharedLibraryCore
public BaseController(IManager manager)
{
InteractionRegistration = manager.InteractionRegistration;
AlertManager = manager.AlertManager;
Manager = manager;
Localization = Utilities.CurrentLocalization.LocalizationIndex;
@ -71,9 +73,7 @@ namespace SharedLibraryCore
CurrentAlias = new EFAlias { Name = "Webfront Guest" }
};
}
protected async Task SignInAsync(ClaimsPrincipal claimsPrinciple)
{
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, claimsPrinciple,
@ -86,7 +86,7 @@ namespace SharedLibraryCore
});
}
public override void OnActionExecuting(ActionExecutingContext context)
public override async void OnActionExecuting(ActionExecutingContext context)
{
if (!HttpContext.Connection.RemoteIpAddress.GetAddressBytes().SequenceEqual(LocalHost))
{
@ -154,6 +154,7 @@ namespace SharedLibraryCore
&& !communityName.Contains("IW4MAdmin")
&& AppConfig.CommunityInformation.IsEnabled;
ViewBag.Interactions = await InteractionRegistration.GetInteractions("Webfront::Nav");
ViewBag.Authorized = Authorized;
ViewBag.Url = AppConfig.WebfrontUrl;
ViewBag.User = Client;

View File

@ -10,6 +10,8 @@ namespace SharedLibraryCore.Helpers;
public class InteractionData : IInteractionData
{
public int? EntityId { get; set; }
public string InteractionId { get; set; }
public InteractionType InteractionType { get; set; }
public bool Enabled { get; set; }
public string Name { get; set; }
public string Description { get; set; }

View File

@ -8,6 +8,8 @@ namespace SharedLibraryCore.Interfaces;
public interface IInteractionData
{
int? EntityId { get; }
string InteractionId { get; }
InteractionType InteractionType { get; }
bool Enabled { get; }
string Name { get; }
string Description { get; }
@ -22,3 +24,10 @@ public interface IInteractionData
InteractionCallback Action { get; }
Delegate ScriptAction { get; }
}
public enum InteractionType
{
ActionButton,
RawContent,
TemplateContent
}

View File

@ -11,7 +11,7 @@ public interface IInteractionRegistration
void RegisterScriptInteraction(string interactionName, string source, Delegate interactionRegistration);
void RegisterInteraction(string interactionName, Func<int?, Reference.Game?, CancellationToken, Task<IInteractionData>> interactionRegistration);
void UnregisterInteraction(string interactionName);
Task<IEnumerable<IInteractionData>> GetInteractions(int? clientId = null,
Task<IEnumerable<IInteractionData>> GetInteractions(string interactionPrefix = null, int? clientId = null,
Reference.Game? game = null, CancellationToken token = default);
Task<string> ProcessInteraction(string interactionId, int originId, int? targetId = null, Reference.Game? game = null, IDictionary<string, string> meta = null, CancellationToken token = default);
}

View File

@ -105,5 +105,6 @@ namespace SharedLibraryCore.Interfaces
event EventHandler<GameEvent> OnGameEventExecuted;
IAlertManager AlertManager { get; }
IInteractionRegistration InteractionRegistration { get; }
}
}