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!
4 replies
ImageColumn make Table rendering so slow
This is my situation: I have db table (ads) without column for image, for retrieve ad's images i have an attribute that return me all links for ad's folder on s3.
In my table i want to show image ad thumbnail.
My attribute (i cannot change this code):
and i set ImageColum like that:
But Table is rendered only when all thumbnails are loaded and "ready" to be displayed.
Is there any way to speed up the table loading?
Thanks in advance
2 replies