Prevent users from removing default guest group
The default guest group is critical and shouldn't be removed without either TShock doing something like automatically recreating it if it doesn't exist, or not having a huge problem if it doesn't exist. I chose to take the easiest path, preventing users from removing it. In theory the message gives enough context to imply "okay, go change the group now." This should be a relatively small edge case but I wanted to resolve it while I was here.
This commit is contained in:
parent
25a7e9e83a
commit
4d46e58865
3 changed files with 11 additions and 3 deletions
|
|
@ -456,6 +456,13 @@ namespace TShockAPI.DB
|
|||
return "Error: Group doesn't exist.";
|
||||
}
|
||||
|
||||
if (name == Group.DefaultGroup.Name)
|
||||
{
|
||||
if (exceptions)
|
||||
throw new GroupManagerException("Unable to remove default guest group.");
|
||||
return "Error: Unable to remove the default guest group.";
|
||||
}
|
||||
|
||||
if (database.Query("DELETE FROM GroupList WHERE GroupName=@0", name) == 1)
|
||||
{
|
||||
groups.Remove(TShock.Groups.GetGroupByName(name));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue