2018-04-14 00:51:38 -04:00
|
|
|
|
using SharedLibraryCore;
|
2018-11-05 22:01:29 -05:00
|
|
|
|
using SharedLibraryCore.Database.Models;
|
2018-04-14 00:51:38 -04:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace IW4MAdmin.Plugins.Login.Commands
|
|
|
|
|
{
|
|
|
|
|
public class CLogin : Command
|
|
|
|
|
{
|
2018-11-05 22:01:29 -05:00
|
|
|
|
public CLogin() : base("login", Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_LOGIN_COMMANDS_LOGIN_DESC"], "li", EFClient.Permission.Trusted, false, new CommandArgument[]
|
2018-04-14 00:51:38 -04:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-08 00:58:46 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_PASSWORD"],
|
2018-04-14 00:51:38 -04:00
|
|
|
|
Required = true
|
|
|
|
|
}
|
2018-09-29 15:52:22 -04:00
|
|
|
|
})
|
|
|
|
|
{ }
|
2018-04-14 00:51:38 -04:00
|
|
|
|
|
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
|
|
|
|
{
|
2019-02-16 16:04:40 -05:00
|
|
|
|
bool success = E.Owner.Manager.TokenAuthenticator.AuthorizeToken(E.Origin.NetworkId, E.Data);
|
2018-04-14 00:51:38 -04:00
|
|
|
|
|
2019-02-16 16:04:40 -05:00
|
|
|
|
if (!success)
|
2018-04-14 00:51:38 -04:00
|
|
|
|
{
|
2019-05-03 21:13:51 -04:00
|
|
|
|
string[] hashedPassword = await Task.FromResult(SharedLibraryCore.Helpers.Hashing.Hash(E.Data, E.Origin.PasswordSalt));
|
|
|
|
|
success = hashedPassword[0] == E.Origin.Password;
|
2019-04-14 11:55:05 -04:00
|
|
|
|
}
|
2019-02-16 16:04:40 -05:00
|
|
|
|
|
2019-04-14 11:55:05 -04:00
|
|
|
|
if (success)
|
|
|
|
|
{
|
|
|
|
|
Plugin.AuthorizedClients[E.Origin.ClientId] = true;
|
2018-04-14 00:51:38 -04:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-16 16:04:40 -05:00
|
|
|
|
_ = success ?
|
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_LOGIN_COMMANDS_LOGIN_SUCCESS"]) :
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_LOGIN_COMMANDS_LOGIN_FAIL"]);
|
2018-04-14 00:51:38 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|