hundreds-match-36539
05/21/2024, 9:31 AMchilly-king-10285
05/21/2024, 9:31 AMchilly-king-10285
05/21/2024, 9:31 AM||
(OR) to combine different conditions. Here is an example of how permissions are defined in OPL: typescript class Document implements Namespace { related: { owners: User[] editors: User[] viewers: User[] parents: Folder[] } permits = { view: (ctx: Context): boolean => this.related.viewers.includes(ctx.subject) || this.related.editors.includes(ctx.subject) || this.related.owners.includes(ctx.subject) || this.related.parents.traverse((parent) => parent.permits.view(ctx)), } }
In this example, the view
permission is granted if the subject is a viewer, editor, or owner of the document, or if the subject can view the parent folder. Each condition is checked using the includes
method, and the results are combined using the ||
operator. For more complex conditions, you might be able to use if conditions in your OPL code, but this is not shown in the provided examples. For more information, you may want to refer to the [Ory documentation](https://www.ory.sh/docs/keto/modeling/create-permission-model#define-permissions-in-the-opl).