diff --git a/Application/Application.csproj b/Application/Application.csproj index 31082d567..4149e746a 100644 --- a/Application/Application.csproj +++ b/Application/Application.csproj @@ -6,7 +6,7 @@ 2.2.2 false RaidMax.IW4MAdmin.Application - 2.2.6.2 + 2.2.6.4 RaidMax Forever None IW4MAdmin @@ -31,8 +31,8 @@ true true - 2.2.6.3 - 2.2.6.3 + 2.2.6.4 + 2.2.6.4 diff --git a/Application/ApplicationManager.cs b/Application/ApplicationManager.cs index 1e6914b2c..87c56a7fd 100644 --- a/Application/ApplicationManager.cs +++ b/Application/ApplicationManager.cs @@ -573,7 +573,7 @@ namespace IW4MAdmin.Application await Task.WhenAll(config.Servers.Select(c => Init(c)).ToArray()); - if (failedServers > 0 && successServers > 0) + if (successServers - failedServers <= 0) { if (!Utilities.PromptBool(Utilities.CurrentLocalization.LocalizationIndex["MANAGER_START_WITH_ERRORS"])) { diff --git a/Plugins/ProfanityDeterment/Plugin.cs b/Plugins/ProfanityDeterment/Plugin.cs index 67712bc0e..7bdd6b627 100644 --- a/Plugins/ProfanityDeterment/Plugin.cs +++ b/Plugins/ProfanityDeterment/Plugin.cs @@ -48,11 +48,7 @@ namespace IW4MAdmin.Plugins.ProfanityDeterment if (containsObjectionalWord) { - E.Origin.Kick(Settings.Configuration().ProfanityKickMessage, new EFClient() - { - ClientId = 1, - CurrentServer = E.Owner - }); + E.Origin.Kick(Settings.Configuration().ProfanityKickMessage, Utilities.IW4MAdminClient(E.Owner)); }; } diff --git a/SharedLibraryCore/Commands/NativeCommands.cs b/SharedLibraryCore/Commands/NativeCommands.cs index fb14ad791..80c474e7d 100644 --- a/SharedLibraryCore/Commands/NativeCommands.cs +++ b/SharedLibraryCore/Commands/NativeCommands.cs @@ -1278,8 +1278,8 @@ namespace SharedLibraryCore.Commands public CNextMap() : base("nextmap", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_NEXTMAP_DESC"], "nm", EFClient.Permission.User, false) { } public static async Task GetNextMap(Server s) { - string mapRotation = (await s.GetDvarAsync("sv_mapRotation")).Value.ToLower(); - var regexMatches = Regex.Matches(mapRotation, @"(gametype +([a-z]{1,4}))? *map ([a-z|_]+)", RegexOptions.IgnoreCase).ToList(); + string mapRotation = (await s.GetDvarAsync("sv_mapRotation")).Value?.ToLower() ?? ""; + var regexMatches = Regex.Matches(mapRotation, @"((?:gametype|exec) +(?:([a-z]{1,4})(?:.cfg)?))? *map ([a-z|_|\d]+)", RegexOptions.IgnoreCase).ToList(); // find the current map in the rotation var currentMap = regexMatches.Where(m => m.Groups[3].ToString() == s.CurrentMap.Name); @@ -1289,7 +1289,7 @@ namespace SharedLibraryCore.Commands // no maprotation at all if (regexMatches.Count() == 0) { - return $"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_NEXTMAP_SUCCESS"].FormatExt(s.CurrentMap.Alias)}/{Utilities.GetLocalizedGametype(s.Gametype)}"; + return Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_NEXTMAP_SUCCESS"].FormatExt(s.CurrentMap.Alias, Utilities.GetLocalizedGametype(s.Gametype)); } // the current map is not in rotation @@ -1318,12 +1318,14 @@ namespace SharedLibraryCore.Commands regexMatches[regexMatches.IndexOf(currentMap.First()) + 1] : regexMatches.First(); - nextMap = s.Maps.FirstOrDefault(m => m.Name == nextMapMatch.Groups[3].ToString()) ?? nextMap; + string nextMapName = nextMapMatch.Groups[3].ToString(); + + nextMap = s.Maps.FirstOrDefault(m => m.Name == nextMapMatch.Groups[3].ToString()) ?? new Map() { Alias = nextMapName, Name = nextMapName }; string nextGametype = nextMapMatch.Groups[2].ToString().Length == 0 ? Utilities.GetLocalizedGametype(s.Gametype) : Utilities.GetLocalizedGametype(nextMapMatch.Groups[2].ToString()); - return $"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_NEXTMAP_SUCCESS"]} ^5{nextMap.Alias}/{nextGametype}"; + return Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_NEXTMAP_SUCCESS"].FormatExt(nextMap.Alias, nextGametype); } public override async Task ExecuteAsync(GameEvent E) diff --git a/SharedLibraryCore/Objects/EFClient.cs b/SharedLibraryCore/Objects/EFClient.cs index d736191f0..da244cedf 100644 --- a/SharedLibraryCore/Objects/EFClient.cs +++ b/SharedLibraryCore/Objects/EFClient.cs @@ -412,6 +412,16 @@ namespace SharedLibraryCore.Database.Models e.FailReason = GameEvent.EventFailReason.Permission; } + else if (Level == newPermission) + { + e.FailReason = GameEvent.EventFailReason.Invalid; + } + + else + { + Level = newPermission; + } + sender.CurrentServer.Manager.GetEventHandler().AddEvent(e); return e; } diff --git a/WebfrontCore/Controllers/ClientController.cs b/WebfrontCore/Controllers/ClientController.cs index d413c0e34..e75ccc313 100644 --- a/WebfrontCore/Controllers/ClientController.cs +++ b/WebfrontCore/Controllers/ClientController.cs @@ -140,9 +140,14 @@ namespace WebfrontCore.Controllers public async Task Meta(int id, int count, int offset, DateTime? startAt) { - var meta = await MetaService.GetRuntimeMeta(id, startAt == null ? offset : 0, count, startAt ?? DateTime.UtcNow); + IEnumerable meta = await MetaService.GetRuntimeMeta(id, startAt == null ? offset : 0, count, startAt ?? DateTime.UtcNow); - if (meta.Count == 0) + if (!Authorized) + { + meta = meta.Where(_meta => !_meta.Sensitive); + } + + if (meta.Count() == 0) { return Ok(); } diff --git a/WebfrontCore/Controllers/ConfigurationController.cs b/WebfrontCore/Controllers/ConfigurationController.cs index adc1eb774..53883142f 100644 --- a/WebfrontCore/Controllers/ConfigurationController.cs +++ b/WebfrontCore/Controllers/ConfigurationController.cs @@ -12,12 +12,22 @@ namespace WebfrontCore.Controllers { public IActionResult Edit() { + if (Client.Level != SharedLibraryCore.Database.Models.EFClient.Permission.Owner) + { + return Unauthorized(); + } + return View("Index", Manager.GetApplicationSettings().Configuration()); } [HttpPost] public async Task Edit(ApplicationConfiguration newConfiguration, bool addNewServer = false, bool shouldSave = false) { + if (Client.Level != SharedLibraryCore.Database.Models.EFClient.Permission.Owner) + { + return Unauthorized(); + } + if (shouldSave) { var currentConfiguration = Manager.GetApplicationSettings().Configuration(); @@ -48,6 +58,11 @@ namespace WebfrontCore.Controllers public IActionResult GetNewListItem(string propertyName, int itemCount) { + if (Client.Level != SharedLibraryCore.Database.Models.EFClient.Permission.Owner) + { + return Unauthorized(); + } + var configInfo = new ConfigurationInfo() { NewItemCount = itemCount, diff --git a/WebfrontCore/ViewComponents/ProfileMetaListViewComponent.cs b/WebfrontCore/ViewComponents/ProfileMetaListViewComponent.cs index 5987753f0..8e4c7a3db 100644 --- a/WebfrontCore/ViewComponents/ProfileMetaListViewComponent.cs +++ b/WebfrontCore/ViewComponents/ProfileMetaListViewComponent.cs @@ -1,6 +1,11 @@ using Microsoft.AspNetCore.Mvc; +using SharedLibraryCore.Database.Models; +using SharedLibraryCore.Dtos; using SharedLibraryCore.Services; using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Claims; using System.Threading.Tasks; namespace WebfrontCore.ViewComponents @@ -9,7 +14,15 @@ namespace WebfrontCore.ViewComponents { public async Task InvokeAsync(int clientId, int count, int offset, DateTime? startAt) { - var meta = await MetaService.GetRuntimeMeta(clientId, offset, count, startAt ?? DateTime.UtcNow); + var level = (EFClient.Permission)Enum.Parse(typeof(EFClient.Permission), UserClaimsPrincipal.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Role)?.Value ?? "User"); + + IEnumerable meta = await MetaService.GetRuntimeMeta(clientId, offset, count, startAt ?? DateTime.UtcNow); + + if (level < EFClient.Permission.Trusted) + { + meta = meta.Where(_meta => !_meta.Sensitive); + } + return View("_List", meta); } } diff --git a/WebfrontCore/Views/Shared/Components/ProfileMetaList/_List.cshtml b/WebfrontCore/Views/Shared/Components/ProfileMetaList/_List.cshtml index 4d973d934..ae91e64c0 100644 --- a/WebfrontCore/Views/Shared/Components/ProfileMetaList/_List.cshtml +++ b/WebfrontCore/Views/Shared/Components/ProfileMetaList/_List.cshtml @@ -1,4 +1,4 @@ -@model List +@model IEnumerable @{ Layout = null; @@ -33,7 +33,7 @@ } } -@if (Model.Count == 0) +@if (Model.Count() == 0) {
@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CLIENT_META_NONE"]
} diff --git a/WebfrontCore/Views/Shared/_Layout.cshtml b/WebfrontCore/Views/Shared/_Layout.cshtml index 0a7005b2e..6860fa0e6 100644 --- a/WebfrontCore/Views/Shared/_Layout.cshtml +++ b/WebfrontCore/Views/Shared/_Layout.cshtml @@ -57,7 +57,10 @@ @@ -76,6 +79,7 @@ +