© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
3 replies
Matteo De Blasis

Custom redirect after login from livewire component

Hello everyone!

I want to redirect to the right panel based on user role.

I have two panels:
-- Role1Panel
-- Role2Panel

and i have three type of users:

-- admin user: he have to redirect to Role1Panel but he can switch the panel (i use Panel Switch by Bezhan Salleh)
-- role1 user: he have to redirect to Role1Panel and he cannot switch the panel
-- role2 user: he have to redirect to Role2Panel and he cannot switch the panel

Each users have a panel column for identify own panel.

I want the"/login" route, i don't need the default login routes of both panels, so i create a Login Livewire component that it use "cleaned" authenticate function, copied by Filament Login page.

Following this guide: https://v2.filamentphp.com/tricks/customize-redirect-after-admin-login, i create a custom LoginResponse class that it use the panel user column for redirect.

The first time login everything works but from there on I am always redirected to the panel of the first login and i don't know why.

This is my authenticate function:

public function authenticate(){
if (! Filament::auth()->attempt(['email' => $this->email, 'password' => $this->password], true)) {
$this->throwFailureValidationException();
}

session()->regenerate();

return app(LoginResponse::class);
}

And my LoginResponse class:

namespace App\Http\Responses;
use Filament\Http\Responses\Auth\Contracts\LoginResponse as LoginResponseContract;
class LoginResponse implements LoginResponseContract
{

/**
* @param $request
* @return \Illuminate\Http\RedirectResponse
*/
public function toResponse($request)
{
$panel = $request->user()->panel ?: 'ramerino';
return redirect()->intended("/$panel");
}
}

thanks in advance!
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Redirect from Livewire component boot()
FilamentFFilament / ❓┊help
2y ago
Livewire custom component - Livewire Sortable
FilamentFFilament / ❓┊help
3y ago
Livewire custom component blank after Popup Called
FilamentFFilament / ❓┊help
16mo ago
Using filament components in custom livewire component
FilamentFFilament / ❓┊help
3y ago