efficiently/authority-controller

Conditional Authorization

Closed this issue · 3 comments

I am trying to allow users to edit their own discussions...
My rule is defined below:

    $authority->allow('edit', 'Discussion', function($self, $discussion){
        return false;
    });

and my check is below:

    @if(Authority::can('edit', $discussion))

no matter what I return in the rule closure (true or false), the check is returned as true...

Any ideas, or am I using something incorrectly? I followed the guides but cant figure out whats going on.

To clarify, I am using route model injection, if that matters...

Hi Kevin,

Did you try this authorization rule in the Laravel console(php artisan tinker) ?
You can read how to debug your authorization rules in this Wiki page.

And be sure that your $discussion varìable contains a Discussion instance.

Cheers,
Tortue Torche

I'm going to close this issue.
If you have still some difficulties, feel free to reopen it.