canAccessPanel how make check for different panel if I use Single Login Panel

In my case I have 4 panel and 1 of them it's auth when in my checks I am check for 3 panel what I have if they assign to role must return true but I have problem $panel->id() return 'auth' panel I need panel to what i am trying log in from my auth panel for exemple if I am truing log in to [email protected] admin panel it must return in $panel->id() ''admin" not "auth" which i am geting
public function canAccessPanel(Panel $panel): bool
{

return match ($panel->getId()) {
RolesEnum::ADMIN->value => $this->hasRole(RolesEnum::ADMIN->value),
RolesEnum::STAFF->value => $this->hasRole(RolesEnum::STAFF->value),
RolesEnum::PLAYER->value => $this->hasRole(RolesEnum::PLAYER->value),
default => false,
};
}
public function canAccessPanel(Panel $panel): bool
{

return match ($panel->getId()) {
RolesEnum::ADMIN->value => $this->hasRole(RolesEnum::ADMIN->value),
RolesEnum::STAFF->value => $this->hasRole(RolesEnum::STAFF->value),
RolesEnum::PLAYER->value => $this->hasRole(RolesEnum::PLAYER->value),
default => false,
};
}
No description
12 Replies
LeandroFerreira
LeandroFerreira2mo ago
/auth/login will return auth panel id /admin/login will return admin panel id
SmereKa
SmereKaOP2mo ago
Problem was when you trying make single login for 3 or more panels then need make auth panel be always true in canAccessPanel
LeandroFerreira
LeandroFerreira2mo ago
I would use a middleware to handle this
SmereKa
SmereKaOP2mo ago
When I was trying to do it I am always got to many redirects in my browser
LeandroFerreira
LeandroFerreira2mo ago
Filament Examples
Filament Multiple Panels: Single Login Page for Admin/User Roles
Having multiple panels is excellent for separating users from other roles. However, managing each different login page can be tricky. So, let's make one login page for all panels and switch redirects based on roles.
SmereKa
SmereKaOP2mo ago
Yes, before I am writing or asking I am digging full internet
LeandroFerreira
LeandroFerreira2mo ago
maybe you could create a minimal repo on github to reproduce this issue
SmereKa
SmereKaOP2mo ago
I solved this just adding “auth” => “true” to my match condition
SmereKa
SmereKaOP2mo ago
GitHub
GitHub - YevheniiVolosiuk/squad-hub: Filament admin panel for manag...
Filament admin panel for manage a team players integrated with discord and more... - YevheniiVolosiuk/squad-hub
SmereKa
SmereKaOP2mo ago
This is repo where I did this
LeandroFerreira
LeandroFerreira2mo ago
solved?
SmereKa
SmereKaOP2mo ago
Yes

Did you find this page helpful?