F
Filamentβ€’2y ago
ddoddsr

Am I using the correct Middleware to Authenticate?

In my config: use App\Http\Middleware\Authenticate; // have also tried with same result // use Filament\Http\Middleware\Authenticate; 'middleware' => [ 'auth' => [ Authenticate::class, ], ... ``` My issue is that even with a user Model with ``` public function canAccessFilament(): bool { return false; } ``` Still all users can access admin pages Also .env has APP_ENV=staging I have seen answers using isFilamentAdmin()` but that is v1, right?
8 Replies
ddoddsr
ddoddsrOPβ€’2y ago
Sorry, cannot fix the backtics
Dennis Koch
Dennis Kochβ€’2y ago
You need triple backticks πŸ˜… Did you clear your config?
ddoddsr
ddoddsrOPβ€’2y ago
yup, art config:clear INFO Configuration cache cleared successfully.
awcodes
awcodesβ€’2y ago
I think the can access filament only matters if the env is production. I could be wrong though.
ddoddsr
ddoddsrOPβ€’2y ago
changes the Authenticate to: use Filament\Http\Middleware\Authenticate; and now I get 403 on both as expected. now returning return $this->is_admin from canAccessFilament method allows the correct one thru, 403sthe correct one. I think I needed the config:clear Also .env has APP_ENV=staging
awcodes
awcodesβ€’2y ago
Hmm. Yea. Looking at the code, staging should be honored the same as production for the middleware.
ddoddsr
ddoddsrOPβ€’2y ago
I think changing back to use Filament\Http\Middleware\Authenticate; did it with a config:clear
Aubrey
Aubreyβ€’2y ago
Was having the same issue and that fixed it! Thank you.
Want results from more Discord servers?
Add your server