F
Filamentβ€’13mo 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
ddoddsrβ€’13mo ago
Sorry, cannot fix the backtics
Dennis Koch
Dennis Kochβ€’13mo ago
You need triple backticks πŸ˜… Did you clear your config?
ddoddsr
ddoddsrβ€’13mo ago
yup, art config:clear INFO Configuration cache cleared successfully.
awcodes
awcodesβ€’13mo ago
I think the can access filament only matters if the env is production. I could be wrong though.
ddoddsr
ddoddsrβ€’13mo 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β€’13mo ago
Hmm. Yea. Looking at the code, staging should be honored the same as production for the middleware.
ddoddsr
ddoddsrβ€’13mo ago
I think changing back to use Filament\Http\Middleware\Authenticate; did it with a config:clear
Unknown User
Unknown Userβ€’13mo ago
Message Not Public
Sign In & Join Server To View