2018-04-14 00:51:38 -04:00
|
|
|
|
using SharedLibraryCore;
|
|
|
|
|
using SharedLibraryCore.Objects;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace IW4MAdmin.Plugins.Login.Commands
|
|
|
|
|
{
|
|
|
|
|
public class CLogin : Command
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
public CLogin() : base("login", Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_LOGIN_COMMANDS_LOGIN_DESC"], "li", Player.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
|
|
|
|
|
}
|
|
|
|
|
}){ }
|
|
|
|
|
|
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
|
|
|
|
{
|
|
|
|
|
var client = E.Owner.Manager.GetPrivilegedClients()[E.Origin.ClientId];
|
|
|
|
|
string[] hashedPassword = await Task.FromResult(SharedLibraryCore.Helpers.Hashing.Hash(E.Data, client.PasswordSalt));
|
|
|
|
|
|
|
|
|
|
if (hashedPassword[0] == client.Password)
|
|
|
|
|
{
|
|
|
|
|
Plugin.AuthorizedClients[E.Origin.ClientId] = true;
|
2018-05-05 16:36:26 -04:00
|
|
|
|
await E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_LOGIN_COMMANDS_LOGIN_SUCCESS"]);
|
2018-04-14 00:51:38 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
await E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_LOGIN_COMMANDS_LOGIN_FAIL"]);
|
2018-04-14 00:51:38 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|