Skip to content

Policy/Gate permission checking with "can" always false #67

@n3storm

Description

@n3storm

Not sure if this is a bug or not. You can close it without any explanation if you think so.

First, our stack is a bit odd because we use TwigBridge and twig templates and we haven't checked the following issue on blade .

{{auth_user().can('update', item)}} returns always false.

Further investigation we discovered that check is false because the DI cannot resolve item as item is a Presentable instance.

As object attribute is protected we cannot straight forward do {{auth_user().can('update', item.object)}}. For this to work had created a trait with method:

public function presentObject()
{
    return $this->object;
}

Now {{auth_user().can('update', item.object)}} works properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions