Search code examples
phplaravellaravel-5.3

Laravel 5.3 auth routes redirecting to /


I just upgraded to Laravel 5.3 (from 5.2) and now have issues with the auth routes.

I implemented the required methonds for the RegisterController and added Auth::routes(); to routes/web.php. But when I access /register I always get redirected to /.

I have no idea why and don't see how I can figure out what's wrong.

The middleware:

protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
        ],
        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];

Update: I found the reason: I was already signed in, therefore it always forwarded me. What I still don't know though, is were it's doing that?


Solution

  • Just found the cause.

    It's in the RedirectIfAuthenticated Middleware:

    if (Auth::guard($guard)->check()) {
         return redirect('/');
    }