-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Hi,
In the "Adding Edit Functionality" (https://docs.adonisjs.com/tutorial/react/authorization#adding-edit-functionality), when i follow this code block:
@inject()
async forDetailedView({ bouncer }: HttpContext) {
return {
...this.toObject(),
can: {
edit: await bouncer.with(PostPolicy).allows('edit', this.resource),
delete: await bouncer.with(PostPolicy).allows('delete', this.resource),
},
}
}
it's produce this in my front console:
RuntimeException: Cannot inject "[Function: Object]" in "[class PostTransformer]"
Hint: The value is not a valid class
...
So, this workaround works for me, with bouncer non-spread:
@inject()
async forDetailedView(ctx: HttpContext) {
return {
...this.toObject(),
can: {
edit: await ctx.bouncer.with(PostPolicy).allows('edit', this.resource),
delete: await ctx.bouncer.with(PostPolicy).allows('delete', this.resource),
},
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels