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

add kick client functionality to webfront home for issue #142

This commit is contained in:
RaidMax
2020-07-14 14:13:40 -05:00
parent 49511cff13
commit 41474768fc
6 changed files with 84 additions and 24 deletions

View File

@ -329,5 +329,48 @@ namespace WebfrontCore.Controllers
command = $"!unflag @{targetId} {reason}"
}));
}
public IActionResult KickForm(int id)
{
var info = new ActionInfo()
{
ActionButtonLabel = Localization["WEBFRONT_ACTION_KICK_NAME"],
Name = "Kick",
Inputs = new List<InputInfo>()
{
new InputInfo()
{
Name = "reason",
Label = Localization["WEBFRONT_ACTION_LABEL_REASON"],
},
new InputInfo()
{
Name = "targetId",
Type = "hidden",
Value = id.ToString()
}
},
Action = "KickAsync",
ShouldRefresh = true
};
return View("_ActionForm", info);
}
public async Task<IActionResult> KickAsync(int targetId, string reason)
{
var client = Manager.GetActiveClients().FirstOrDefault(_client => _client.ClientId == targetId);
if (client == null)
{
return BadRequest(Localization["WEBFRONT_ACTION_KICK_DISCONNECT"]);
}
return await Task.FromResult(RedirectToAction("ExecuteAsync", "Console", new
{
serverId = client.CurrentServer.EndPoint,
command = $"!kick {client.ClientNumber} {reason}"
}));
}
}
}