Permission nodes
This commit is contained in:
parent
0b02b90df0
commit
e22f3e03c4
1 changed files with 32 additions and 19 deletions
|
|
@ -173,6 +173,19 @@ namespace TShockAPI
|
|||
/// <param name="permission">The permission to check.</param>
|
||||
/// <returns>Returns true if the user has that permission.</returns>
|
||||
public virtual bool HasPermission(string permission)
|
||||
{
|
||||
string[] nodes = permission.Split('.');
|
||||
for (int i = nodes.Length - 1; i >= 0; i--)
|
||||
{
|
||||
if (RealHasPermission(String.Join(".", nodes)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
nodes[i] = "*";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private bool RealHasPermission(string permission)
|
||||
{
|
||||
if (string.IsNullOrEmpty(permission))
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue