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

WithoutMiddleware doesn't work on global middleware #32384

Closed
nmokkenstorm opened this issue Apr 15, 2020 · 5 comments
Closed

WithoutMiddleware doesn't work on global middleware #32384

nmokkenstorm opened this issue Apr 15, 2020 · 5 comments
Labels

Comments

@nmokkenstorm
Copy link
Contributor

nmokkenstorm commented Apr 15, 2020

  • Laravel Version: 7.6.1
  • PHP Version: 7.3.16
  • Database Driver & Version: N/A

Description:

A recent commit added the option to skip/disable middleware for specific routes, which works for Route Groups and the like, but the implementation for global middleware doesn't actually check for it yet. I'm willing to look into a fix for this, but wanted to raise an issue first to check if such a fix would be welcome.

Steps To Reproduce:

Require a Auth middleware for all your routes in the App\Http\Kernel, try to call ->withoutMiddleware on login.

@driesvints
Copy link
Member

I'm not sure if it was intended to skip global middleware. You're free to attempt a pr however.

@driesvints
Copy link
Member

Heya. I'm gonna re-open this as it indeed seems to be expected to work with global middleware as well. Thanks for reporting.

@nmokkenstorm
Copy link
Contributor Author

@driesvints , @dsazup thanks for the feedback, I'd love to work on a PR for this tonight, will keep you both in the loop.

@driesvints
Copy link
Member

Closing this as the PR was rejected. Please see the explanation by Taylor here: #32404 (comment)

@bernardwiesner
Copy link
Contributor

bernardwiesner commented Dec 20, 2021

btw you can exclude a global middleware like this inside Kernel.php

    public function handle($request)
    {
        if($request->is('/your/route')){
            $index = array_search(SomeMiddleware::class, $this->middleware);
            unset($this->middleware[$index]);
        }
        return parent::handle($request);
    }

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

No branches or pull requests

3 participants