Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

christian_H's avatar

What methods are being called when a logged in user makes a get request to /login in Spark?

I'm using Spark 1.0's default auth routing and methods. What I am trying to figure out is what is happening when an authenticated user makes a get request to /login. Here is the route:

$router->get('/login', 'Auth\LoginController@showLoginForm');

And here is the showLoginForm method in the controller

public function showLoginForm()
    {
        Log::info("Showing Login Form");
        return view('spark::auth.login');
    }

So as you can see I have a debug message in there to let me know when that method is hit. Everything works as expected when a user who isn't currently logged in accesses this route. I get the debug message and then they get the view. However, if a user who is already logged in accesses that route, then it doesn't seem like that controller method is being used at all. Instead they are redirected to /home. I am trying to track down where this redirect is occurring. The only middleware running on this route is Spark's default web Middleware group. I took a look at the different middleware's that are part of this group, but it doesn't seem like any of them are redirecting. This is the middleware that's a part of the web middleware group but like I said I don't see the redirect logic in any of them.

protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Laravel\Spark\Http\Middleware\CreateFreshApiToken::class,
        ],

Can anyone tell me where this redirect logic is coming from, and why the route isn't using the correct controller method? I just need some logic to change what is being returned depending on the user type but I can't even figure out where the request is going since it isn't hitting the specified controller method. Thanks

0 likes
1 reply
christian_H's avatar
christian_H
OP
Best Answer
Level 1

Found it right after I posted this. Its the RedirectAfterAuthenticated Middleware. Sorry guys, if someone will tell me how to delete this post I will.

Please or to participate in this conversation.