update default permissions for guest webfront users
This commit is contained in:
parent
76925a78d4
commit
3295315339
@ -1,21 +1,25 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using SharedLibraryCore;
|
using SharedLibraryCore;
|
||||||
using SharedLibraryCore.Configuration;
|
using SharedLibraryCore.Configuration;
|
||||||
using SharedLibraryCore.Dtos;
|
using SharedLibraryCore.Dtos;
|
||||||
using SharedLibraryCore.Interfaces;
|
using SharedLibraryCore.Interfaces;
|
||||||
using SharedLibraryCore.Services;
|
using SharedLibraryCore.Services;
|
||||||
|
using ILogger = Microsoft.Extensions.Logging.ILogger;
|
||||||
|
|
||||||
namespace IW4MAdmin.Application.Misc;
|
namespace IW4MAdmin.Application.Misc;
|
||||||
|
|
||||||
public class RemoteCommandService : IRemoteCommandService
|
public class RemoteCommandService : IRemoteCommandService
|
||||||
{
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
private readonly ApplicationConfiguration _appConfig;
|
private readonly ApplicationConfiguration _appConfig;
|
||||||
private readonly ClientService _clientService;
|
private readonly ClientService _clientService;
|
||||||
|
|
||||||
public RemoteCommandService(ApplicationConfiguration appConfig, ClientService clientService)
|
public RemoteCommandService(ILogger<RemoteCommandService> logger, ApplicationConfiguration appConfig, ClientService clientService)
|
||||||
{
|
{
|
||||||
|
_logger = logger;
|
||||||
_appConfig = appConfig;
|
_appConfig = appConfig;
|
||||||
_clientService = clientService;
|
_clientService = clientService;
|
||||||
}
|
}
|
||||||
@ -23,6 +27,13 @@ public class RemoteCommandService : IRemoteCommandService
|
|||||||
public async Task<IEnumerable<CommandResponseInfo>> Execute(int originId, int? targetId, string command,
|
public async Task<IEnumerable<CommandResponseInfo>> Execute(int originId, int? targetId, string command,
|
||||||
IEnumerable<string> arguments, Server server)
|
IEnumerable<string> arguments, Server server)
|
||||||
{
|
{
|
||||||
|
if (originId < 1)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Not executing command {Command} for {Originid} because origin id is invalid", command,
|
||||||
|
originId);
|
||||||
|
return Enumerable.Empty<CommandResponseInfo>();
|
||||||
|
}
|
||||||
|
|
||||||
var client = await _clientService.Get(originId);
|
var client = await _clientService.Get(originId);
|
||||||
client.CurrentServer = server;
|
client.CurrentServer = server;
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ namespace SharedLibraryCore
|
|||||||
Client = new EFClient
|
Client = new EFClient
|
||||||
{
|
{
|
||||||
ClientId = -1,
|
ClientId = -1,
|
||||||
Level = Data.Models.Client.EFClient.Permission.Banned,
|
Level = Data.Models.Client.EFClient.Permission.User,
|
||||||
CurrentAlias = new EFAlias { Name = "Webfront Guest" }
|
CurrentAlias = new EFAlias { Name = "Webfront Guest" }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,12 @@ namespace WebfrontCore.Controllers
|
|||||||
public class ConsoleController : BaseController
|
public class ConsoleController : BaseController
|
||||||
{
|
{
|
||||||
private readonly IRemoteCommandService _remoteCommandService;
|
private readonly IRemoteCommandService _remoteCommandService;
|
||||||
|
private readonly ITranslationLookup _translationLookup;
|
||||||
|
|
||||||
public ConsoleController(IManager manager, IRemoteCommandService remoteCommandService) : base(manager)
|
public ConsoleController(IManager manager, IRemoteCommandService remoteCommandService, ITranslationLookup translationLookup) : base(manager)
|
||||||
{
|
{
|
||||||
_remoteCommandService = remoteCommandService;
|
_remoteCommandService = remoteCommandService;
|
||||||
|
_translationLookup = translationLookup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
@ -33,6 +35,17 @@ namespace WebfrontCore.Controllers
|
|||||||
|
|
||||||
public async Task<IActionResult> Execute(long serverId, string command)
|
public async Task<IActionResult> Execute(long serverId, string command)
|
||||||
{
|
{
|
||||||
|
if (Client.ClientId < 1)
|
||||||
|
{
|
||||||
|
return Ok(new[]
|
||||||
|
{
|
||||||
|
new CommandResponseInfo
|
||||||
|
{
|
||||||
|
Response = _translationLookup["SERVER_COMMANDS_INTERCEPTED"]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var server = Manager.GetServers().First(s => s.EndPoint == serverId);
|
var server = Manager.GetServers().First(s => s.EndPoint == serverId);
|
||||||
var response = await _remoteCommandService.Execute(Client.ClientId, null, command, Enumerable.Empty<string>(), server);
|
var response = await _remoteCommandService.Execute(Client.ClientId, null, command, Enumerable.Empty<string>(), server);
|
||||||
return !response.Any() ? StatusCode(400, response) : Ok(response);
|
return !response.Any() ? StatusCode(400, response) : Ok(response);
|
||||||
|
Loading…
Reference in New Issue
Block a user