-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
[5.2] Create Authorize middleware and AuthorizesResources trait #12913
Conversation
* @param string $name | ||
* @param string $model | ||
* @param array $options | ||
* @param \Illuminate\Http\Request $request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing |null
6e89bbd
to
273f32f
Compare
be1532d
to
9d47f39
Compare
9d47f39
to
abdd9e0
Compare
*/ | ||
public function handle($request, Closure $next, $ability, $model = null) | ||
{ | ||
$this->gate->authorize($ability, $this->getGateArguments($model)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getGateArguments($request, $model), missing $request
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mark86092 thanks for catching that!
Just goes to show that you always need tests. So I now wrote a test for the middleware too (it was originally in the laravel/laravel repo, which has no tests).
abdd9e0
to
541d2b2
Compare
541d2b2
to
b9ce61c
Compare
b9ce61c
to
6549156
Compare
They've been merged into Laravel: laravel/framework#12913 For Laravel 5.1, here's some more information: #82
They've been merged into Laravel: laravel/framework#12913 For Laravel 5.1, here's some more information: JosephSilber/bouncer#82
1. A new
Authorize
middlewareCan be used with a simple ability:
Can be used on a single model:
It will pull the
$user
model from the route.Finally, it can be used on a model type:
2. A new
AuthorizesResources
traitWill automatically add the correct middleware to authorize any request for the resource.