Redirect to app panel instead of admin panel
I have an admin panel and an app panel. The default() is added on the admin panel.
Each time I try to login a user (after invitation email) using auth()->login($user); it would redirect to the admin panel.
Is there a way I can 'force' to go to the app panel?
4 Replies
How are you inviting users?
Like this one: https://www.youtube.com/watch?v=YpK16Z6Hr14&t=85s
In fact, when the invite user action I create an invitation entry in a table. Then the invited user clicks on the link in the mail and the following is executed
public function create(): void
{
$this->invitationModel = Invitation::find($this->invitation); $user = User::create([ 'name' => $this->form->getState()['name'], 'email' => $this->invitationModel->email, 'password' =>Hash::make($this->form->getState()['password']), ]); $user->organizations()->attach($this->invitationModel->organization_id); auth()->login($user); //this one goes to admin panel because it's default() but I need it to go to app (user) panel $this->redirect(Dashboard::getUrl()); }
$this->invitationModel = Invitation::find($this->invitation); $user = User::create([ 'name' => $this->form->getState()['name'], 'email' => $this->invitationModel->email, 'password' =>Hash::make($this->form->getState()['password']), ]); $user->organizations()->attach($this->invitationModel->organization_id); auth()->login($user); //this one goes to admin panel because it's default() but I need it to go to app (user) panel $this->redirect(Dashboard::getUrl()); }
Shouldn't there be a redirect anywhere? I don't think
auth()->login()
will redirect youCorrect, there is a $this->redirect(Dashboard::getURL()). But as said, that redirects to the Admin panel (as it's the default()). What I would like is that it redirects to the App panel.
I have 'fixed' it as follows:
if (Filament::getPanel()->getId() === 'admin') {
Filament::getPanel('app')->auth()->login($user);
$this->redirect(route('filament.app.resources.products.index', ['tenant' => $this->invitationModel->organization_id]));
session()->regenerate();
}
But this does not feel correct and efficient.