|
|
|
@ -174,18 +174,18 @@ namespace Squidex.Shared |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static Permission ForApp(string id, string app = Permission.Any, string schema = Permission.Any) |
|
|
|
public static bool Allows(this PermissionSet permissions, string id, string app = Permission.Any, string schema = Permission.Any) |
|
|
|
{ |
|
|
|
Guard.NotNull(id, nameof(id)); |
|
|
|
var permission = ForApp(id, app, schema); |
|
|
|
|
|
|
|
return new Permission(id.Replace("{app}", app ?? Permission.Any).Replace("{name}", schema ?? Permission.Any)); |
|
|
|
return permissions.Allows(permission); |
|
|
|
} |
|
|
|
|
|
|
|
public static PermissionSet ToAppPermissions(this PermissionSet permissions, string app) |
|
|
|
public static Permission ForApp(string id, string app = Permission.Any, string schema = Permission.Any) |
|
|
|
{ |
|
|
|
var matching = permissions.Where(x => x.StartsWith($"squidex.apps.{app}")); |
|
|
|
Guard.NotNull(id, nameof(id)); |
|
|
|
|
|
|
|
return new PermissionSet(matching); |
|
|
|
return new Permission(id.Replace("{app}", app ?? Permission.Any).Replace("{name}", schema ?? Permission.Any)); |
|
|
|
} |
|
|
|
|
|
|
|
public static string[] ToAppNames(this PermissionSet permissions) |
|
|
|
|