cold-motorcycle-49371
07/09/2023, 11:54 AMclass StorageObject implements Namespace {
related: {
viewers: User[]
editors: User[]
owners: User[]
}
permits = {
read: (ctx: Context): boolean =>
this.related.viewers.includes(ctx.subject) ||
this.related.editors.includes(ctx.subject) ||
this.related.owners.includes(ctx.subject)
}
}
Instead of mentioning owner
, editor
and viewer
in all the applicable permission, Is there a way that I can say,
everything that the viewer has access, the owner has access too
?steep-lamp-91158
isMember
helper permission:
class StorageObject implements Namespace {
related: {
viewers: User[]
editors: User[]
owners: User[]
}
permits = {
isMember: (ctx: Context): boolean =>
this.related.viewers.includes(ctx.subject) ||
this.related.editors.includes(ctx.subject) ||
this.related.owners.includes(ctx.subject),
read: (ctx: Context): boolean =>
this.permits.isMember(ctx)
}
}
steep-lamp-91158
cold-motorcycle-49371
07/10/2023, 3:19 PMsteep-lamp-91158
steep-lamp-91158