Skip to content

Commit

Permalink
feat: Add Matching Funcs to IEnforcer interface (#339)
Browse files Browse the repository at this point in the history
* Add funcs to ienforcer

* Change AddMatchingFuncs to not return the updated enforcer
  • Loading branch information
zredinger-ccc authored Feb 13, 2024
1 parent 54db948 commit befbb33
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Casbin/Extensions/Enforcer/EnforcerExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,30 +342,26 @@ public static void SetRoleManager(this IEnforcer enforcer, string roleType, IRol
}
}

public static Enforcer AddMatchingFunc(this Enforcer enforcer, Func<string, string, bool> func)
public static void AddMatchingFunc(this IEnforcer enforcer, Func<string, string, bool> func)
{
enforcer.AddNamedMatchingFunc(PermConstants.DefaultRoleType, func);
return enforcer;
}

public static Enforcer AddDomainMatchingFunc(this Enforcer enforcer, Func<string, string, bool> func)
public static void AddDomainMatchingFunc(this IEnforcer enforcer, Func<string, string, bool> func)
{
enforcer.AddNamedDomainMatchingFunc(PermConstants.DefaultRoleType, func);
return enforcer;
}

public static Enforcer AddNamedMatchingFunc(this Enforcer enforcer, string roleType,
public static void AddNamedMatchingFunc(this IEnforcer enforcer, string roleType,
Func<string, string, bool> func)
{
enforcer.Model.GetRoleManger(roleType).AddMatchingFunc(func);
return enforcer;
}

public static Enforcer AddNamedDomainMatchingFunc(this Enforcer enforcer, string roleType,
public static void AddNamedDomainMatchingFunc(this IEnforcer enforcer, string roleType,
Func<string, string, bool> func)
{
enforcer.Model.GetRoleManger(roleType).AddMatchingFunc(func);
return enforcer;
}

#endregion
Expand Down

0 comments on commit befbb33

Please sign in to comment.