-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Allow passing multiple gaurds to the auth middleware #3685
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
Conversation
I think the check might should be changed to |
Thoughts? |
aaf5766
to
703197e
Compare
@taylorotwell updated. |
return response('Unauthorized.', 401); | ||
} else { | ||
return redirect()->guest('login'); | ||
if ($this->check($guards)) { |
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.
Looks weird to put success condition before failed condition, in Middleware.
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.
It's not weird at all. You just maybe haven't seen it be done that way.
I actually like it quite a bit. It decreases the level of indentation, which is always a good thing.
Would anyone ever want this to be an "and" check instead of an "or" check? |
For an "and" check, you can just run the middleware twice: ->middleware('auth|auth:api'); |
Make it OR please. Not every JSON request is an AJAX request. |
And why "allow" has become synonymous with "make it mandatory"?! Why |
Allow passing multiple gaurds to the auth middleware
|
Using this, you'd be able to allow access to a single route for multiple guards: