Table of Contents
If you're dealing with a 403 error when signing up on your FilamentPHP application, don't worry. There's a simple fix to get your email verification working properly.
Step 1: Update AdminPanelProviders
First, ensure you have ->emailVerification() added in your app/Providers/Filament/AdminPanelProviders.php within the panel method. It should look something like this:
<?php
public function panel(Panel $panel): void
{
$panel
->login()
->registration()
->passwordReset()
->emailVerification() // < This right here
}
Step 2: Modify the User Model
This is where the FilamentPHP documentation is slightly misleading. Documentation says that you need to add $this->hasVerifiedEmail() in the canAccessPanel method. But if you're implementing Illuminate\Contracts\Auth\MustVerifyEmail then you don't need that. Instead, it should simply return true. Here's how you should do it:
<?php
use Filament\Panel;
...
public function canAccessPanel(Panel $panel): bool
{
return true;
}
Finally, just make sure that your User Model implements FilamentUser and MustVerifyEmail (as stated above as well). So, your user model should look like this:
<?php
use Filament\Models\Contracts\FilamentUser;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Filament\Panel;
class User extends Authenticatable implements FilamentUser, MustVerifyEmail
{
// Your User Model code
public function canAccessPanel(Panel $panel): bool
{
return true;
}
}
Summary
That's it! Just follow these steps:
- Add
->emailVerification()inAdminPanelProviders.php. - Ensure
canAccessPanelmethod returnstruein the User Model. - Make sure the User Model implements
FilamentUserandMustVerifyEmail.
By making these changes, you should resolve the 403 error and get your email verification working seamlessly.
If you have any questions or run into issues, feel free to reach out. Happy coding!