2020-01-26 19:06:50 -05:00
|
|
|
|
using SharedLibraryCore.Configuration;
|
|
|
|
|
using SharedLibraryCore.Database.Models;
|
|
|
|
|
using SharedLibraryCore.Interfaces;
|
2019-02-16 16:04:40 -05:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace SharedLibraryCore.Commands
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generates a token for use in webfront login
|
|
|
|
|
/// </summary>
|
2019-02-16 16:04:40 -05:00
|
|
|
|
public class RequestTokenCommand : Command
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public RequestTokenCommand(CommandConfiguration config, ITranslationLookup lookup) : base(config, lookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "requesttoken";
|
|
|
|
|
Description = lookup["COMMANDS_GENERATETOKEN_DESC"];
|
|
|
|
|
Alias = "rt";
|
|
|
|
|
Permission = EFClient.Permission.Trusted;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
}
|
2019-02-16 16:04:40 -05:00
|
|
|
|
|
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
|
|
|
|
{
|
|
|
|
|
var state = E.Owner.Manager.TokenAuthenticator.GenerateNextToken(E.Origin.NetworkId);
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(string.Format(_translationLookup["COMMANDS_GENERATETOKEN_SUCCESS"], state.Token, $"{state.RemainingTime} {_translationLookup["GLOBAL_MINUTES"]}", E.Origin.ClientId));
|
2019-02-16 16:04:40 -05:00
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|