sendEmailVerificationNotification (Admin created users)

In my app the admin registers the users, ie the registration page is disabled. I enabled MustVerifyEmail however that does not trigger emails to go out. I found a workaround to send the emails however when the user clicks the link it always says invalid signature and I do not understand why. If the user simply tries to login without clicking the link in the email, they are presented with the resend email, which then works. Any help on how to properly send the verify email notification when an admin creates another user would be greatly appreciated.
class User extends Authenticatable implements FilamentUser, MustVerifyEmail
{
use HasFactory, HasUuids, Notifiable, SoftDeletes, HasApiTokens;

protected static function booted()
{
static::created(function ($model): void {

// The code below states that the Route [verification.verify] not defined.
// event(new Registered($model));
// $model->sendEmailVerificationNotification();

// This sends the email but the signature is always invalid
$notification = app(VerifyEmail::class);
$notification->url = Filament::getVerifyEmailUrl($model);
$model->notify($notification);
});
}
}
class User extends Authenticatable implements FilamentUser, MustVerifyEmail
{
use HasFactory, HasUuids, Notifiable, SoftDeletes, HasApiTokens;

protected static function booted()
{
static::created(function ($model): void {

// The code below states that the Route [verification.verify] not defined.
// event(new Registered($model));
// $model->sendEmailVerificationNotification();

// This sends the email but the signature is always invalid
$notification = app(VerifyEmail::class);
$notification->url = Filament::getVerifyEmailUrl($model);
$model->notify($notification);
});
}
}
6 Replies
BigBlueMonkey
BigBlueMonkeyOP3d ago
Some progress - I added the below to routes/web.php but I would have assumed this should be added by filament should it not?
// This route shows the email verification notice (e.g., "Please verify your email")
Route::get('/email/verify', function () {
return view('auth.verify-email'); // Or your custom view
})->middleware('auth')->name('verification.notice');

// This route handles the verification itself (signed URL)
Route::get('/email/verify/{id}/{hash}', function (EmailVerificationRequest $request) {
$request->fulfill(); // Marks the email as verified
return redirect()->to('/'); // Redirect after verification, e.g., to dashboard
})->middleware(['auth', 'signed'])->name('verification.verify');

// This route resends the verification email
Route::post('/email/resend', function (Request $request) {
$request->user()->sendEmailVerificationNotification();
return back()->with('resent', true);
})->middleware(['auth', 'throttle:6,1'])->name('verification.send');
// This route shows the email verification notice (e.g., "Please verify your email")
Route::get('/email/verify', function () {
return view('auth.verify-email'); // Or your custom view
})->middleware('auth')->name('verification.notice');

// This route handles the verification itself (signed URL)
Route::get('/email/verify/{id}/{hash}', function (EmailVerificationRequest $request) {
$request->fulfill(); // Marks the email as verified
return redirect()->to('/'); // Redirect after verification, e.g., to dashboard
})->middleware(['auth', 'signed'])->name('verification.verify');

// This route resends the verification email
Route::post('/email/resend', function (Request $request) {
$request->user()->sendEmailVerificationNotification();
return back()->with('resent', true);
})->middleware(['auth', 'throttle:6,1'])->name('verification.send');
Dennis Koch
Dennis Koch3d ago
They are added by Filament if you use ->emailVerification() on the Panel.
however when the user clicks the link it always says invalid signature and I do not understand why
This might happen when you have a redirect. E.g. Your app uses https but emails are sent out with http. Or a trailing slash is removed.
BigBlueMonkey
BigBlueMonkeyOP2d ago
->emailVerifcation is used on the panel. I can also see
GET|HEAD email-verification/verify/{id}/{hash} ........................................................................................... filament.admin.auth.email-verification.verify › Filament\Auth › EmailVerificationController
GET|HEAD email-verification/verify/{id}/{hash} ........................................................................................... filament.admin.auth.email-verification.verify › Filament\Auth › EmailVerificationController
in the routes list. but that does not align with what the app is looking for (ie verification.verify) For some reason its trying to use the default laravel route?!
Dennis Koch
Dennis Koch2d ago
Search your codebase for that route. Maybe you used it somewhere else?
BigBlueMonkey
BigBlueMonkeyOP17h ago
No, search revealed no use other than what I had copied in - can you confirm that on a clean install with ->emailVerification() [NOT registration()] this is functioning?! ie it is picking up filament.admin.auth.email-verification.verify rather than verification.verify as the route?
Dennis Koch
Dennis Koch16h ago
I just did this a week ago and didn't have any issues. Ah wait. You probably use the wrong VerifyEmail. Filament\Auth\Notifications\VerifyEmail not Illuminate\Auth\Notifications\VerifyEmail

Did you find this page helpful?