FilamentF
Filament11mo ago
Sjoerd

emailVerification redirects to login

After clicking the link in the mail for email verification the user gets instantly redirected to the login page. I can't find out why this is happening, maybe a config issue which I haven't found in the docs. Already spent quite some hours on solving this, hope someone can help me out.

My panel config I believe is quite basic and I have added emailVerification()

  return $panel
    ->default()
    ->id('admin')
    ->path('admin')
    ->emailVerification()
    ->passwordReset()
    ->login()
    ->profile()
    ->colors([
        'primary' => Color::Violet,
    ])
    ->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
    ->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
    ->pages([
        Pages\Dashboard::class,
    ])
    ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
    ->widgets([
        Widgets\AccountWidget::class,
        Widgets\FilamentInfoWidget::class,
    ])
    ->middleware([
        EncryptCookies::class,
        AddQueuedCookiesToResponse::class,
        StartSession::class,
        AuthenticateSession::class,
        ShareErrorsFromSession::class,
        VerifyCsrfToken::class,
        SubstituteBindings::class,
        DisableBladeIconComponents::class,
        DispatchServingFilamentEvent::class,
    ])
    ->authMiddleware([
        Authenticate::class,
    ]);


To send the verification email I have created a Listener, which may not be best practice?

$notification = app(VerifyEmail::class);
$notification->url = Filament::getVerifyEmailUrl($user);

$user->notify($notification);


My User class:

class User extends Authenticatable implements FilamentUser, MustVerifyEmail
{
    use CanResetPassword, HasFactory, Notifiable;
    ...


The email is sent and I can click the link in it after which it redirects to login. Any suggestion would be greatly appreciated!
Was this page helpful?