Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Add forbid, forbid_if and forbid_unless helpers #48447

Closed
wants to merge 1 commit into from

Conversation

karkowg
Copy link
Contributor

@karkowg karkowg commented Sep 19, 2023

Small nicety on top of abort, abort_if and abort_unless but dedicated to throwing unauthorized exceptions (403).

forbid('You shall not pass!');

@milwad-dev
Copy link
Contributor

I don't agree

@driesvints
Copy link
Member

@milwad-dev instead of saying "I don't agree" please state your reasoning.

@morloderex
Copy link
Contributor

morloderex commented Sep 19, 2023

@karkowg wouldn't it be better to use throw_if and throw_unless for this, and then just throw the Illuminate\Auth\Access\AuthorizationException?

My reasoning is that Illuminate\Auth\Access\AuthorizationException's underlying response could have been modified and just by using the abort_if and abort_unless helpers respectively we are by-passing this customisation?

@taylorotwell
Copy link
Member

I honestly don't mind this method but fear it opens the door to a PR for every single status code imaginable. 😅

@taylorotwell
Copy link
Member

Feel free to define in your own project. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants