Added additional properties method to allow easier extension to client properties
updated VPN plugin to use WebClient message is sent to client trying to execute commands before they are authenticated fixed rare issue with ToAdmins failing record bullet distance fraction for client kills (_customcallbacks) change client level/permissions through webfront ability to tempban through webfront
This commit is contained in:
@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SharedLibraryCore;
|
||||
using WebfrontCore.ViewModels;
|
||||
using static SharedLibraryCore.Objects.Player;
|
||||
|
||||
namespace WebfrontCore.Controllers
|
||||
{
|
||||
@ -22,6 +23,20 @@ namespace WebfrontCore.Controllers
|
||||
{
|
||||
Name = "Reason",
|
||||
Label = Localization["WEBFRONT_ACTION_LABEL_REASON"],
|
||||
},
|
||||
new InputInfo()
|
||||
{
|
||||
Name ="Duration",
|
||||
Label=Localization["WEBFRONT_ACTION_LABEL_DURATION"],
|
||||
Type="select",
|
||||
Values = new Dictionary<string, string>()
|
||||
{
|
||||
{"1", $"1 {Localization["GLOBAL_TIME_HOUR"]}" },
|
||||
{"2", $"6 {Localization["GLOBAL_TIME_HOURS"]}" },
|
||||
{"3", $"1 {Localization["GLOBAL_TIME_DAY"]}" },
|
||||
{"4", $"1 {Localization["GLOBAL_TIME_WEEK"]}" },
|
||||
{"5", $"{Localization["WEBFRONT_ACTION_SELECTION_PERMANENT"]}" },
|
||||
}
|
||||
}
|
||||
},
|
||||
Action = "BanAsync"
|
||||
@ -30,14 +45,36 @@ namespace WebfrontCore.Controllers
|
||||
return View("_ActionForm", info);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> BanAsync(int targetId, string Reason)
|
||||
public async Task<IActionResult> BanAsync(int targetId, string Reason, int Duration)
|
||||
{
|
||||
string duration = string.Empty;
|
||||
|
||||
switch (Duration)
|
||||
{
|
||||
case 1:
|
||||
duration = "1h";
|
||||
break;
|
||||
case 2:
|
||||
duration = "6h";
|
||||
break;
|
||||
case 3:
|
||||
duration = "1d";
|
||||
break;
|
||||
case 4:
|
||||
duration = "1w";
|
||||
break;
|
||||
}
|
||||
|
||||
string command = Duration == 5 ?
|
||||
$"!ban @{targetId} {Reason}" :
|
||||
$"!tempban @{targetId} {duration} {Reason}";
|
||||
|
||||
var server = Manager.GetServers().First();
|
||||
|
||||
return await Task.FromResult(RedirectToAction("ExecuteAsync", "Console", new
|
||||
{
|
||||
serverId = server.GetHashCode(),
|
||||
command = $"!ban @{targetId} {Reason}"
|
||||
command
|
||||
}));
|
||||
}
|
||||
|
||||
@ -102,5 +139,42 @@ namespace WebfrontCore.Controllers
|
||||
{
|
||||
return await Task.FromResult(RedirectToAction("LoginAsync", "Account", new { clientId, password }));
|
||||
}
|
||||
|
||||
public IActionResult EditForm()
|
||||
{
|
||||
var info = new ActionInfo()
|
||||
{
|
||||
ActionButtonLabel = Localization["WEBFRONT_ACTION_LABEL_EDIT"],
|
||||
Name = "Edit",
|
||||
Inputs = new List<InputInfo>()
|
||||
{
|
||||
new InputInfo()
|
||||
{
|
||||
Name ="level",
|
||||
Label=Localization["WEBFRONT_PROFILE_LEVEL"],
|
||||
Type="select",
|
||||
Values = Enum.GetValues(typeof(Permission)).OfType<Permission>()
|
||||
.Where(p => p <= Client.Level)
|
||||
.Where(p => p != Permission.Banned)
|
||||
.Where(p => p != Permission.Flagged)
|
||||
.ToDictionary(p => p.ToString(), p=> p.ToLocalizedLevelName())
|
||||
},
|
||||
},
|
||||
Action = "EditAsync"
|
||||
};
|
||||
|
||||
return View("_ActionForm", info);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> EditAsync(int targetId, string level)
|
||||
{
|
||||
var server = Manager.GetServers().First();
|
||||
|
||||
return await Task.FromResult(RedirectToAction("ExecuteAsync", "Console", new
|
||||
{
|
||||
serverId = server.GetHashCode(),
|
||||
command = $"!setlevel @{targetId} {level}"
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using static SharedLibraryCore.Objects.Penalty;
|
||||
|
||||
namespace WebfrontCore.Controllers
|
||||
{
|
||||
@ -20,6 +21,8 @@ namespace WebfrontCore.Controllers
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var activePenalties = await Manager.GetPenaltyService().GetActivePenaltiesAsync(client.AliasLinkId, client.IPAddress);
|
||||
|
||||
#if DEBUG
|
||||
Authorized = true;
|
||||
#endif
|
||||
@ -48,6 +51,7 @@ namespace WebfrontCore.Controllers
|
||||
.Distinct()
|
||||
.OrderBy(i => i)
|
||||
.ToList(),
|
||||
HasActivePenalty = activePenalties.Count > 0,
|
||||
Online = Manager.GetActiveClients().FirstOrDefault(c => c.ClientId == client.ClientId) != null,
|
||||
TimeOnline = (DateTime.UtcNow - client.LastConnection).TimeSpanText(),
|
||||
LinkedAccounts = client.LinkedAccounts
|
||||
|
Reference in New Issue
Block a user