#Logout Route

44 messages · Page 1 of 1 (latest)

sage shore
#

Is there a way to modify the default logout route? I just want to point it in the root url.

wooden sableBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

tidal ether
#

You need override LogouteResponse

hushed fjord
sage shore
#

Wow, thank you for your responses!

sage shore
worn apex
#

This isnt useful for many situations

chrome cove
wooden sableBOT
worn apex
chrome cove
worn apex
#

  at vendor/laravel/framework/src/Illuminate/Routing/AbstractRouteCollection.php:248
    244▕             $route->name($this->generateRouteName());
    245▕ 
    246▕             $this->add($route);
    247▕         } elseif (! is_null($symfonyRoutes->get($name))) {
  ➜ 248▕             throw new LogicException("Unable to prepare route [{$route->uri}] for serialization. Another route has already been assigned name [{$name}].");
    249▕         }
    250▕ 
    251▕         $symfonyRoutes->add($route->getName(), $route->toSymfonyRoute());
    252▕ 

      +34 vendor frames 

  35  artisan:16
      Illuminate\Foundation\Application::handleCommand(Object(Symfony\Component\Console\Input\ArgvInput))```
#

sorry, overide method

#

Route::post('/logout', [LogoutController::class, 'logout'])->name('filament.admin.auth.logout');

#

tried with /admin/logout

#

like @limpid spruce told

#

it works in local env, not in prod

grave helm
#

Don’t override the route. Swap the LogoutResponse class in a service provider.

chrome cove
grave helm
#

Don’t know why it wouldn’t work. 🤷

chrome cove
grave helm
#

Odd.

worn apex
#
    public function logout(Request $request)
    {

        $id_token = session('efaas_id_token');

        // Use EXACT URL registered with eFaas (hardcoded)
        $post_logout_redirect_url = '/admin/login';

        session()->forget(['efaas_id_token', 'efaas_sid', 'efaas_sub', 'auth_method']);

        Auth::logout();

        if ($id_token) {
            return Socialite::driver('efaas')->logOut($id_token, $post_logout_redirect_url);
        }

        return redirect($post_logout_redirect_url);
    }
}```
worn apex
#

the issue with Logout Response is, when i try to dd $id_token = session('efaas_id_token'), its null. so when the request comes to logoutresponse, it is already cleared, however, to logOut i need that to pass.

grave helm
#

I would think Socialite has an easy way to handle logout redirects. But I’m not sure this is a filament issue since it depends on Socialite for the auth flow and thus not going through filaments authenticate middleware. I’m sure I’m missing something though.

grave helm
#

Is there anyway you can figure out, without your changes which LogoutController class is being called? Ie, without trying to change anything, is it from Socialite or Filament?

chrome cove
# worn apex Come on, i said im sorry

No bad feelings at all. You just didn't give any information we can work with. If you said why it wasn't useful, we could maybe provide other solutions.

worn apex
worn apex
#

so i kinda fixed it

#
                'logout' => MenuItem::make()
                    ->label('Log out')
                    ->url(function () {
                        return session('auth_method') === 'efaas'
                            ? '/admin/logout'  // Direct URL generation
                            : url('/logout');
                    }),```
#
Route::post('logout', \Filament\Http\Controllers\Auth\LogoutController::class)->name('filament.logout'); ```
#

dont know if this is not the a bad idea

#

anyone?

grave helm
#

I just don’t understand why you have multiple logout controllers?

worn apex
#

Our Government Provider requires some special procedures like this, ``` $id_token = session('efaas_id_token');

    // Use EXACT URL registered with eFaas (hardcoded)
    $post_logout_redirect_url = config('services.efaas.logout_redirect_url');

    session()->forget(['efaas_id_token', 'efaas_sid', 'efaas_sub', 'auth_method']);

    Auth::logout();

    if ($id_token) {
        return Socialite::driver('efaas')->logOut($id_token, $post_logout_redirect_url);
    }

    return redirect('/');```

other wise it wont logout fully, the session already exist. So to use this i have to make a Login Controller, else it interfere with the Filaments login controller

grave helm
worn apex
grave helm
#

Ah, just meant to look at the code and see how they are handling things.

#

I’m out of ideas though, I don’t see why overriding the respective classes wouldn’t work. 🤷