canAccessPanel() Not being called

I am triying to secure access but my canAccessPanel() is not being called. I am using FilamentUser contract in User. And below is my code. to test i am always retirnung false but i am still able to access panel. I cleared all caches.
public function canAccessPanel(Panel $panel): bool
{
dd('canAccessPanel is being called!');
return false;

$panelId = $panel->getId();
if ($panelId === 'labaiq-team') {
return $this->user_type === 'platform_team_member' && str_ends_with($this->email, '@labaiq.com') && $this->email_verified_at;
}

if($panelId === 'user' || $panelId === 'company'){

return $this->user_type === 'general_user';
}


return false;
}
public function canAccessPanel(Panel $panel): bool
{
dd('canAccessPanel is being called!');
return false;

$panelId = $panel->getId();
if ($panelId === 'labaiq-team') {
return $this->user_type === 'platform_team_member' && str_ends_with($this->email, '@labaiq.com') && $this->email_verified_at;
}

if($panelId === 'user' || $panelId === 'company'){

return $this->user_type === 'general_user';
}


return false;
}
4 Replies
Dennis Koch
Dennis Koch3d ago
Is your environment local?
Pritbor
PritborOP3d ago
Hi @Dennis Koch . I tested in both local and production.
Tin
Tin2d ago
I suggest looking if you have a piece of code that does this: Gate::before(function ($user, $ability) { return $user->super_admin == 1 ? true : null; }); But that is just a hunch
Dennis Koch
Dennis Koch2d ago
Do you implement the interface on the user model?

Did you find this page helpful?