Missing group safeguards.
- Server will no longer start up when the guest or default groups cannot be located. - Players joining with unknown groups assigned to them will be disconnected with an error
This commit is contained in:
parent
c5421460ae
commit
48370d74b7
6 changed files with 41 additions and 5 deletions
|
|
@ -823,10 +823,13 @@ namespace TShockAPI
|
|||
(usingUUID && account.UUID == args.Player.UUID && !TShock.Config.Settings.DisableUUIDLogin &&
|
||||
!String.IsNullOrWhiteSpace(args.Player.UUID)))
|
||||
{
|
||||
args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, account.ID);
|
||||
|
||||
var group = TShock.Groups.GetGroupByName(account.Group);
|
||||
|
||||
if (!TShock.Utils.AssertGroupValid(args.Player, group))
|
||||
return;
|
||||
|
||||
args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, account.ID);
|
||||
|
||||
args.Player.Group = group;
|
||||
args.Player.tempGroup = null;
|
||||
args.Player.Account = account;
|
||||
|
|
|
|||
|
|
@ -202,6 +202,21 @@ namespace TShockAPI.DB
|
|||
Group.DefaultGroup = GetGroupByName(TShock.Config.Settings.DefaultGuestGroupName);
|
||||
}
|
||||
|
||||
internal void EnsureCoreGroupsPresent()
|
||||
{
|
||||
if (!GroupExists(TShock.Config.Settings.DefaultGuestGroupName))
|
||||
{
|
||||
TShock.Log.ConsoleError("The guest group could not be found. This may indicate a typo in the configuration file, or that the group was renamed or deleted.");
|
||||
throw new Exception("The guest group could not be found.");
|
||||
}
|
||||
|
||||
if(!GroupExists(TShock.Config.Settings.DefaultRegistrationGroupName))
|
||||
{
|
||||
TShock.Log.ConsoleError("The default usergroup could not be found. This may indicate a typo in the configuration file, or that the group was renamed or deleted.");
|
||||
throw new Exception("The default usergroup could not be found.");
|
||||
}
|
||||
}
|
||||
|
||||
private void AddDefaultGroup(string name, string parent, string permissions)
|
||||
{
|
||||
if (!GroupExists(name))
|
||||
|
|
|
|||
|
|
@ -2450,10 +2450,13 @@ namespace TShockAPI
|
|||
args.Player.State = 2;
|
||||
NetMessage.SendData((int)PacketTypes.WorldInfo, args.Player.Index);
|
||||
|
||||
args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, account.ID);
|
||||
|
||||
var group = TShock.Groups.GetGroupByName(account.Group);
|
||||
|
||||
if (!TShock.Utils.AssertGroupValid(args.Player, group))
|
||||
return true;
|
||||
|
||||
args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, account.ID);
|
||||
|
||||
args.Player.Group = group;
|
||||
args.Player.tempGroup = null;
|
||||
args.Player.Account = account;
|
||||
|
|
@ -3004,6 +3007,9 @@ namespace TShockAPI
|
|||
|
||||
var group = TShock.Groups.GetGroupByName(account.Group);
|
||||
|
||||
if (!TShock.Utils.AssertGroupValid(args.Player, group))
|
||||
return true;
|
||||
|
||||
args.Player.Group = group;
|
||||
args.Player.tempGroup = null;
|
||||
args.Player.Account = account;
|
||||
|
|
|
|||
|
|
@ -322,6 +322,7 @@ namespace TShockAPI
|
|||
Regions = new RegionManager(DB);
|
||||
UserAccounts = new UserAccountManager(DB);
|
||||
Groups = new GroupManager(DB);
|
||||
Groups.EnsureCoreGroupsPresent();
|
||||
ProjectileBans = new ProjectileManagager(DB);
|
||||
TileBans = new TileManager(DB);
|
||||
RememberedPos = new RememberedPosManager(DB);
|
||||
|
|
|
|||
|
|
@ -212,6 +212,17 @@ namespace TShockAPI
|
|||
} while (TilePlacementValid(tileX, tileY) && TileSolid(tileX, tileY));
|
||||
}
|
||||
|
||||
public bool AssertGroupValid(TSPlayer player, Group group)
|
||||
{
|
||||
if (group == null)
|
||||
{
|
||||
player.Disconnect("Your account's group could not be found. Please contact server administrators about this.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if a tile is valid.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 8c2c087327bbd1f20ff6c46f4d11e5714e57064b
|
||||
Subproject commit 4b555bc373dbb470bc69ebed69c79de116f28df2
|
||||
Loading…
Add table
Add a link
Reference in a new issue