Add remaining backbone for banning accounts (sort of)

Frontend still doesn't work properly. In particular:

1. Need a way to list bans by account name.
2. Need a way to unban by account name.
3. Really need a way to change the IP on a ban lol.

Ban system still needs to be be rebuilt fully, but at least this
doesn't necessarily character ban someone if you were going for an IP
ban.

Fixes #1412
This commit is contained in:
Lucas Nicodemus 2017-12-02 20:41:14 -07:00
parent 0edfc6834f
commit 718525904a
5 changed files with 60 additions and 11 deletions

View file

@ -472,6 +472,28 @@ namespace TShockAPI
args.Player.User.KnownIps = JsonConvert.SerializeObject(KnownIps, Formatting.Indented);
Users.UpdateLogin(args.Player.User);
Ban potentialBan = Bans.GetBanByAccountName(args.Player.User.Name);
if (potentialBan != null)
{
// A user just signed in successfully despite being banned by account name.
// We should fix the ban database so that all of their ban info is up to date.
Bans.AddBan2(args.Player.IP, args.Player.Name, args.Player.UUID, args.Player.User.Name,
potentialBan.Reason, false, potentialBan.BanningUser, potentialBan.Expiration);
// And then get rid of them.
if (potentialBan.Expiration == "")
{
Utils.ForceKick(args.Player, String.Format("Permanently banned by {0} for {1}", potentialBan.BanningUser
,potentialBan.Reason), false, false);
}
else
{
Utils.ForceKick(args.Player, String.Format("Still banned by {0} for {1}", potentialBan.BanningUser,
potentialBan.Reason), false, false);
}
}
}
/// <summary>OnAccountDelete - Internal hook fired on account delete.</summary>
@ -488,7 +510,7 @@ namespace TShockAPI
CharacterDB.SeedInitialData(Users.GetUser(args.User));
}
/// <summary>OnPlayerPreLogin - Internal hook fired when on player pre login.</summary>
/// <summary>OnPlayerPreLoginOnPlayerPreLogin - Internal hook fired when on player pre login.</summary>
/// <param name="args">args - The PlayerPreLoginEventArgs object.</param>
private void OnPlayerPreLogin(Hooks.PlayerPreLoginEventArgs args)
{