Tricks

Admin panel 403 in production

May 30, 2022
Dan Harrin
Admin panel, FAQ

If you've deployed your Filament admin panel to a non-local environment and you're receiving 403 Forbidden errors when trying to access it, it's likely that you've forgotten to set up your User model to access Filament.

You must implement the FilamentUser contract:

<?php
 
namespace App\Models;
 
use Filament\Models\Contracts\FilamentUser;
use Illuminate\Foundation\Auth\User as Authenticatable;
 
class User extends Authenticatable implements FilamentUser
{
// ...
 
public function canAccessFilament(): bool
{
return str_ends_with($this->email, '@yourdomain.com') && $this->hasVerifiedEmail();
}
}

The canAccessFilament() method returns true or false depending on whether the user is allowed to access Filament. In this example, we check if the user's email ends with @yourdomain.com and if they have verified their email address.

You can find this information in our documentation.

No comments yet…