From 444c81c5aac920562d71b902de9626736e66e396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Falc=C3=B3n?= Date: Tue, 3 Feb 2026 22:59:28 +0100 Subject: [PATCH] chore: Sync users to Resend after email verification (#98) ## Summary - Changed `SyncUserToResendListener` to listen to the `Verified` event instead of `Registered`, so contacts are only created in Resend after the user verifies their email address - Updated corresponding tests to use the `Verified` event ## Test plan - [x] `SyncUserToResendListenerTest` passes with `Verified` event - [x] All auth and listener tests pass --- app/Listeners/SyncUserToResendListener.php | 4 ++-- tests/Feature/Listeners/SyncUserToResendListenerTest.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Listeners/SyncUserToResendListener.php b/app/Listeners/SyncUserToResendListener.php index cb0842b9..004746ee 100644 --- a/app/Listeners/SyncUserToResendListener.php +++ b/app/Listeners/SyncUserToResendListener.php @@ -3,7 +3,7 @@ namespace App\Listeners; use App\Services\ResendService; -use Illuminate\Auth\Events\Registered; +use Illuminate\Auth\Events\Verified; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Support\Facades\Log; @@ -11,7 +11,7 @@ class SyncUserToResendListener implements ShouldQueue { public function __construct(public ResendService $resendService) {} - public function handle(Registered $event): void + public function handle(Verified $event): void { if (! config('services.resend.key')) { Log::warning('Resend API key not configured, skipping contact sync'); diff --git a/tests/Feature/Listeners/SyncUserToResendListenerTest.php b/tests/Feature/Listeners/SyncUserToResendListenerTest.php index 26aab6a6..e0d54ede 100644 --- a/tests/Feature/Listeners/SyncUserToResendListenerTest.php +++ b/tests/Feature/Listeners/SyncUserToResendListenerTest.php @@ -3,7 +3,7 @@ use App\Listeners\SyncUserToResendListener; use App\Models\User; use App\Services\ResendService; -use Illuminate\Auth\Events\Registered; +use Illuminate\Auth\Events\Verified; use Illuminate\Support\Facades\Log; use function Pest\Laravel\mock; @@ -21,7 +21,7 @@ test('user is synced to resend contacts', function () { ->once() ->with(Mockery::on(fn ($u) => $u->id === $user->id)); - (new SyncUserToResendListener($resendService))->handle(new Registered($user)); + (new SyncUserToResendListener($resendService))->handle(new Verified($user)); }); test('listener skips sync when api key is not configured', function () { @@ -36,5 +36,5 @@ test('listener skips sync when api key is not configured', function () { $user = User::factory()->create(); - (new SyncUserToResendListener($resendService))->handle(new Registered($user)); + (new SyncUserToResendListener($resendService))->handle(new Verified($user)); });