Issues with Email Verification Redirect in Filament/Laravel Setup

Hi everyone, I'm facing an issue in my Filament + Laravel project related to email verification. After verifying an email, the user is redirected to the login page instead of the intended success page. I've tried several approaches, including Laravel's default verification, a custom VerificationController, and Filament's built-in methods, but nothing has worked. Key Details: Custom Controller: Handles verification but fails to redirect correctly. Filament Setup: Tried reverting to Filament's ->emailVerification() method, no change. Simplified Routes: Used basic Laravel routes, issue persists. Problem: Users are redirected to the login page instead of the success page (/verification-success) after verifying their email. Code Fragments: VerificationController:
<?php
public function verify(Request $request, $id, $hash)
{
$user = Auth::user();
if ($id != $user->getKey() || !hash_equals($hash, sha1($user->getEmailForVerification()))) {
return Redirect::route('login')->with('error', 'Invalid verification link.');
}
if ($user->markEmailAsVerified()) {
event(new Verified($user));
}
return redirect($this->redirectTo)->with('success', 'Your email has been verified successfully.');
}
<?php
public function verify(Request $request, $id, $hash)
{
$user = Auth::user();
if ($id != $user->getKey() || !hash_equals($hash, sha1($user->getEmailForVerification()))) {
return Redirect::route('login')->with('error', 'Invalid verification link.');
}
if ($user->markEmailAsVerified()) {
event(new Verified($user));
}
return redirect($this->redirectTo)->with('success', 'Your email has been verified successfully.');
}
Email Verification Class:
class EmailVerification extends EmailVerificationPrompt
{
public function mount(): void
{
if ($this->getVerifiable()->hasVerifiedEmail()) {
redirect()->route('custom.verification.success')->send();
}
}

public function fulfillVerification(EmailVerificationRequest $request)
{
$request->fulfill();
return redirect()->route('custom.verification.success');
}
}
class EmailVerification extends EmailVerificationPrompt
{
public function mount(): void
{
if ($this->getVerifiable()->hasVerifiedEmail()) {
redirect()->route('custom.verification.success')->send();
}
}

public function fulfillVerification(EmailVerificationRequest $request)
{
$request->fulfill();
return redirect()->route('custom.verification.success');
}
}
Has anyone experienced something similar? Any suggestions would be greatly appreciated! Thanks!
25 Replies
Sir. NioH
Sir. NioH3mo ago
Remember that I use the super duper filament kit template.
LeandroFerreira
LeandroFerreira3mo ago
Filament supports email verification. You need to add this in your panel $panel->emailVerification() and implement MustVerifyEmail contract https://laravel.com/docs/11.x/verification#model-preparation
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
Sir. NioH
Sir. NioH3mo ago
thank you very much for replying but yes I have tried that too, : ]) ->path('admin') ->login(Login::class) ->passwordReset(RequestPasswordReset::class) ->emailVerification(EmailVerification::class) and class User extends Authenticatable implements FilamentUser, MustVerifyEmail, HasAvatar, HasName, HasMedia
LeandroFerreira
LeandroFerreira3mo ago
same issue? php artisan about --only=Filament What is the Filament version? Could you try this in a Filament fresh install?
Sir. NioH
Sir. NioH3mo ago
Filament ...........................................................................................................
Packages ........................................................... filament, forms, notifications, support, tables
Version .................................................................................................... v3.2.97
Views ..................................................................................... PUBLISHED: notifications
Filament ...........................................................................................................
Packages ........................................................... filament, forms, notifications, support, tables
Version .................................................................................................... v3.2.97
Views ..................................................................................... PUBLISHED: notifications
I tried to install filament super duper kit in a clean way without any configuration but I didn't get it either, I tried in the verificationController class to define where it will be redirected to but neither, in spite of all my attempts I don't know which part forces to send to the login of the panel:
class VerificationController extends Controller
{
use VerifiesEmails;

/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = '/verification-success'; // Cambia esto a la ruta deseada

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
}
class VerificationController extends Controller
{
use VerifiesEmails;

/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = '/verification-success'; // Cambia esto a la ruta deseada

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
}
LeandroFerreira
LeandroFerreira3mo ago
but I didn't get it either what is the issue?
Sir. NioH
Sir. NioH3mo ago
ok as I said above whatever changes you make or I can think of a user after pressing the email verification is directed directly to the login and I was hoping to put after the user presses the verification button some blade.
Sir. NioH
Sir. NioH3mo ago
No description
Sir. NioH
Sir. NioH3mo ago
I have found some posts that talk about this in older versions of laravel, but it hasn't worked for me I don't know if my template I use super duperkit in some plugin or some file defines this I have searched but I haven't had much luck with the things I have modified.
No description
LeandroFerreira
LeandroFerreira3mo ago
if you want , you can create a minimal repo on github to reproduce this issue, I can have a look after
Sir. NioH
Sir. NioH3mo ago
of course I want it hehe I'm intrigued to know what my error or what happened to the redirection after verification I will upload immediately the minimum version you recommended to isolate the problem.
Sir. NioH
Sir. NioH3mo ago
GitHub
GitHub - StikAlexander/route-pos-verification-email-try-change: ple...
please help me to find out who is in charge of redirecting the newly verified user to the login. - StikAlexander/route-pos-verification-email-try-change
Sir. NioH
Sir. NioH3mo ago
🙏🏻 thanks
LeandroFerreira
LeandroFerreira2mo ago
It looks like you’ve made some customizations to your project. I’ve enabled the registration form and noticed a few bugs. These issues don’t appear to be related to Filament itself but rather to the custom changes you’ve implemented. If you’d like some help, please provide a minimal repository that replicates this specific issue
No description
Sir. NioH
Sir. NioH2mo ago
The changes I made to the repository I gave you were very minimal. Look, let's do the following: if you're okay with it, I'll send you the link to the Super Duper Starter Kit directly. If it's possible to implement the function of redirecting the user after verification, I'm sure that if I see an example, I'll learn how to edit it in my more advanced project in the future. Does that sound good, or does it go against the chat rules? Let me know, thanks a lot. 🫶🏻
Sir. NioH
Sir. NioH2mo ago
Filament
SuperDuper Starter Kit by Rio Dewanto P - Filament
A start point to kickstart your next app. Features a Custom Theme, Mail Configuration, Shield, Exception, and more!
awcodes
awcodes2mo ago
Shouldn’t the redirect just be handled in a middleware? That’s the only guaranteed place to know anything about the authenticated user.
Sir. NioH
Sir. NioH2mo ago
hello awcode the truth I have tried so many things and tips and none of them work for me haha it is very simple I am looking for the user after pressing the verification email to be taken to a blade where it says verification successful login, I feel that the default verification is functional but crude ie you press verify and it sends you immediately to the login 😅 `<?php namespace App\Http\Responses\Auth; use Filament\Http\Responses\Auth\EmailVerificationResponse as BaseEmailVerificationResponse; use Illuminate\Http\RedirectResponse; use Livewire\Features\SupportRedirects\Redirector; class CustomEmailVerificationResponse extends BaseEmailVerificationResponse { public function toResponse($request): RedirectResponse | Redirector { return redirect()->route('custom.verification.success'); ` the last thing they recommended me was to try with the EmailVerificationResponse file, but as it always gives the same result nothing happens the user is sent to login
awcodes
awcodes2mo ago
Then something else is happening in your app. The verification should redirect to a login with a message that an email has been sent. So, yes they can’t log in at that point but the login screen is less important than the message saying they need to check their email. And when they click the link in the email, they get verified and can then login or be logging automatically by the verification token in the link.
Sir. NioH
Sir. NioH2mo ago
Umm, as far as I know, it works fine. Let me quickly explain the flow: a user is created, they receive the verification email, click on verify, and are sent to the login page. They log in, and that's it. At verification, it stops being null. If this behavior is wrong, please let me know, as this is how it comes by default in the Super Duper Starter Kit template 😦
awcodes
awcodes2mo ago
Ok, but I don’t know what the super duper starter kit is. If you are having issues it sounds like an issue with that.
Sir. NioH
Sir. NioH2mo ago
It's a plugin or template maybe ?, and I understand. I don't want to waste much of your time. If it's a plugin error, it's best to migrate my project away from that template. I'll try that eventually, thanks. 🙏🏻
awcodes
awcodes2mo ago
Reach out to the plugin author.
Sir. NioH
Sir. NioH2mo ago
yes i already tried, sorry i will close the post thanks for the advice
awcodes
awcodes2mo ago
You don’t have to close it. Some one might have an answer. But it’s hard to help in the general help thread when any plugin is involved.
Want results from more Discord servers?
Add your server