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
Sorry, cannot fix the backtics
You need triple backticks π
Did you clear your config?
yup, art config:clear
INFO Configuration cache cleared successfully.
I think the can access filament only matters if the env is production. I could be wrong though.
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=stagingHmm. Yea. Looking at the code, staging should be honored the same as production for the middleware.
I think changing back to
use Filament\Http\Middleware\Authenticate;
did it with a config:clearWas having the same issue and that fixed it! Thank you.