Added hardcoded superadmin group
This commit is contained in:
parent
bb2e9559f0
commit
6f3f53f0dc
2 changed files with 38 additions and 1 deletions
|
|
@ -9,6 +9,8 @@ namespace TShockAPI
|
|||
{
|
||||
private string name;
|
||||
private Group parent = null;
|
||||
private List<string> permissions = new List<string>();
|
||||
private List<string> negatedPermissions = new List<string>();
|
||||
|
||||
public Group(string groupName, Group parentGroup = null)
|
||||
{
|
||||
|
|
@ -16,6 +18,11 @@ namespace TShockAPI
|
|||
parent = parentGroup;
|
||||
}
|
||||
|
||||
public Group()
|
||||
{
|
||||
throw new System.Exception("Called Group constructor with no parameters");
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return name;
|
||||
|
|
@ -28,7 +35,35 @@ namespace TShockAPI
|
|||
|
||||
public bool HasPermission(string permission)
|
||||
{
|
||||
//TODO: implement this
|
||||
if (negatedPermissions.Contains(permission))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (permissions.Contains(permission))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (parent != null)
|
||||
{
|
||||
//inception
|
||||
return parent.HasPermission(permission);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class SuperAdminGroup : Group
|
||||
{
|
||||
public SuperAdminGroup(string groupName, Group parentGroup = null) : base(groupName, parentGroup)
|
||||
{
|
||||
}
|
||||
|
||||
public SuperAdminGroup() : base()
|
||||
{
|
||||
}
|
||||
|
||||
new public bool HasPermission(string permission)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -321,6 +321,8 @@ namespace TShockAPI
|
|||
|
||||
private static void LoadGroups()
|
||||
{
|
||||
groups = new List<Group>();
|
||||
groups.Add(new SuperAdminGroup("superadmin"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue