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.
Solution
Error was due to using the Custom authentication middleware in all my panels. I had commented out Authenticate::class from all auth middleware. Filament native authenticate middleware calls canAccessPanel() method directly. Whereas I implemented CustomAuthenticate::class and removed filament one which caused and issue. Fix was to include this below peice of code in my CustomAuthentciate.