Skip to content

Call Policy / Gate, if available, even if ability granted #264

@garygreen

Description

@garygreen

In our system, admins have access to do everything:

Bouncer::allow('admin')->everything();

We have a user messaging system and use a MessagePolicy class to check if you are allowed to send a message to a user. In our case, we don't need the "everything" ability to grant access, even though they are an admin - we want the MessagePolicy to always fire but bouncer automatically intersects Gate::authorize('send', $message) with Bouncer granted permission via ability #18 [all abilities]

Would it be possible to have a way of telling bouncer to ignore certain abilities for one check, maybe a closure?

Bouncer::ignore('*', function() {
    Gate::authorize('send', $message); // MessagePolicy will be checked and the absolute source of truth.
});

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions