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
This commit is contained in:
Víctor Falcón 2026-02-03 22:59:28 +01:00 committed by GitHub
parent 370d388d99
commit 444c81c5aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -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');

View File

@ -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));
});