The EventServiceProvider of the AppShell library extends the Illuminate\Foundation\Support\Providers\EventServiceProvider class.
Beginning with Laravel 11, this automatically registers the Illuminate\Auth\Listeners\SendEmailVerificationNotification class as an event listener for the Illuminate\Auth\Events\Registered event. See Illuminate\Foundation\Support\Providers\EventServiceProvider::configureEmailVerification() function.
If AppShell is loaded as a Concord module, Illuminate\Foundation\Support\Providers\EventServiceProvider::register() will be called (at least) twice, resulting that the SendEmailVerificationNotification class will be registered (at least) twice as the listener for the Registered event.
What we did in our project to solve this issue:
- Defined our own
EventServiceProvider extending Illuminate\Foundation\Support\Providers\EventServiceProvider and overwriting the configureEmailVerification() function to do nothing.
- Extended our own
EventServiceProvider in every Concord module instead of the Illuminate\Foundation\Support\Providers\EventServiceProvider
Because we could not change the EventServiceProvider of the AppShell module, it still extended Illuminate\Foundation\Support\Providers\EventServiceProvider, thus we had 2 registrations of the SendEmailVerificationNotification listener, so we
- Defined a
Noop listener:
namespace App\Listeners;
class Noop
{
public function handle()
{
// No operation
}
}
- And bound it to the
Illuminate\Auth\Listeners\SendEmailVerificationNotification::class in App\Providers\AppServiceProvider::register()
$this->app->bind(
\Illuminate\Auth\Listeners\SendEmailVerificationNotification::class,
\App\Listeners\Noop::class
);
- Defined our own
App\Listeners\SendEmailVerificationNotification listener. This will automatically get registered by Laravel 11.
namespace App\Listeners;
use Illuminate\Auth\Events\Registered;
use Illuminate\Contracts\Auth\MustVerifyEmail;
class SendEmailVerificationNotification
{
/**
* Handle the event.
*
* @param Registered $event
* @return void
*/
public function handle(Registered $event)
{
if ($event->user instanceof MustVerifyEmail && ! $event->user->hasVerifiedEmail()) {
$event->user->sendEmailVerificationNotification();
}
}
}
It would be nice to have a workaround in the AppShell module so that other users don`t have to follow these steps 😉.
The
EventServiceProviderof the AppShell library extends theIlluminate\Foundation\Support\Providers\EventServiceProviderclass.Beginning with Laravel 11, this automatically registers the
Illuminate\Auth\Listeners\SendEmailVerificationNotificationclass as an event listener for theIlluminate\Auth\Events\Registeredevent. SeeIlluminate\Foundation\Support\Providers\EventServiceProvider::configureEmailVerification()function.If AppShell is loaded as a Concord module,
Illuminate\Foundation\Support\Providers\EventServiceProvider::register()will be called (at least) twice, resulting that theSendEmailVerificationNotificationclass will be registered (at least) twice as the listener for theRegisteredevent.What we did in our project to solve this issue:
EventServiceProviderextendingIlluminate\Foundation\Support\Providers\EventServiceProviderand overwriting theconfigureEmailVerification()function to do nothing.EventServiceProviderin every Concord module instead of theIlluminate\Foundation\Support\Providers\EventServiceProviderBecause we could not change the
EventServiceProviderof the AppShell module, it still extendedIlluminate\Foundation\Support\Providers\EventServiceProvider, thus we had 2 registrations of theSendEmailVerificationNotificationlistener, so weNooplistener:Illuminate\Auth\Listeners\SendEmailVerificationNotification::classinApp\Providers\AppServiceProvider::register()App\Listeners\SendEmailVerificationNotificationlistener. This will automatically get registered by Laravel 11.It would be nice to have a workaround in the AppShell module so that other users don`t have to follow these steps 😉.