#Logout Route
44 messages · Page 1 of 1 (latest)
Yes
You need override LogouteResponse
https://filamentphp.com/content/tim-wassenburg-how-to-customize-logout-redirect
here is a tutorial for your exact problem, I just implemented it and it works fine for me
Wow, thank you for your responses!
For those that will stumble this kind of question again in the near future. This is the answer
This isnt useful for many situations
Without any explanation your comment also isn't useful.
Thank you for marking this question as solved!
Im sorry. I meant that logout response, instead there should be a way to override the logout controller, I didnt mean in a bad way 😄
No sure whether it's possible to swap out controllers.
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
Don’t override the route. Swap the LogoutResponse class in a service provider.
Apparently that's "not useful". Whatever that means
Don’t know why it wouldn’t work. 🤷
Not sure either. There was another thread:
https://discord.com/channels/883083792112300104/1419260921150308412
Odd.
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);
}
}```
Come on, i said im sorry
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.
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.
thank you
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?
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.
POST admin/logout filament.admin.auth.logout › Filament\Http › LogoutC…
GET|HEAD admin/logout filament.admin.auth.logout › App\Filament\Pages\Auth…
POST parent/logout filament.parent.auth.logout › Filament\Http › Logou…
POST student/logout filament.student.auth.logout › Filament\Http › Log…```
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?
I just don’t understand why you have multiple logout controllers?
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
Maybe have a look at how this plugin handles everything: https://github.com/DutchCodingCompany/filament-socialite
already tried, there is a package for that, which is not compatible with this, https://github.com/Javaabu/EFaas-Socialite