b51af7ca9a
make bad GUID parse throw an exception so we don't have a client connect with GUID of 0 no longer print out ac debug messages fix small issue of trying to parse empty chat messages fix issue with set level on accounts with multi guid, same IP
41 lines
1.5 KiB
C#
41 lines
1.5 KiB
C#
using SharedLibraryCore;
|
|
using SharedLibraryCore.Database.Models;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace IW4MAdmin.Plugins.Login.Commands
|
|
{
|
|
public class CLogin : Command
|
|
{
|
|
public CLogin() : base("login", Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_LOGIN_COMMANDS_LOGIN_DESC"], "li", EFClient.Permission.Trusted, false, new CommandArgument[]
|
|
{
|
|
new CommandArgument()
|
|
{
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_PASSWORD"],
|
|
Required = true
|
|
}
|
|
})
|
|
{ }
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
|
{
|
|
var client = E.Owner.Manager.PrivilegedClients[E.Origin.ClientId];
|
|
bool success = E.Owner.Manager.TokenAuthenticator.AuthorizeToken(E.Origin.NetworkId, E.Data);
|
|
|
|
if (!success)
|
|
{
|
|
string[] hashedPassword = await Task.FromResult(SharedLibraryCore.Helpers.Hashing.Hash(E.Data, client.PasswordSalt));
|
|
success = hashedPassword[0] == client.Password;
|
|
}
|
|
|
|
if (success)
|
|
{
|
|
Plugin.AuthorizedClients[E.Origin.ClientId] = true;
|
|
}
|
|
|
|
_ = success ?
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_LOGIN_COMMANDS_LOGIN_SUCCESS"]) :
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_LOGIN_COMMANDS_LOGIN_FAIL"]);
|
|
}
|
|
}
|
|
}
|