An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(profile): close the email change modal after verification
Andras Bacsai9c6a8e47673c
diff --git a/app/Livewire/Profile/Index.php b/app/Livewire/Profile/Index.phpindex a69424cffd..8801ffac36 100644--- a/app/Livewire/Profile/Index.php+++ b/app/Livewire/Profile/Index.php@@ -222,6 +222,7 @@ class Index extends Component$this->show_verification = false;$this->dispatch('success', 'Email address updated successfully.');+ $this->dispatch('close-email-change-modal');auditLog('ui.user.email_changed', $this->auditContext());} else {$this->dispatch('error', 'Failed to update email address.');diff --git a/tests/Feature/ProfileEmailChangeModalTest.php b/tests/Feature/ProfileEmailChangeModalTest.phpnew file mode 100644index 0000000000..da4f6f3b31--- /dev/null+++ b/tests/Feature/ProfileEmailChangeModalTest.php@@ -0,0 +1,40 @@+<?php++use App\Livewire\Profile\Index as ProfileIndex;+use App\Models\User;+use Illuminate\Foundation\Testing\RefreshDatabase;+use Livewire\Livewire;++uses(RefreshDatabase::class);++beforeEach(function () {+ $this->user = User::factory()->create(['name' => 'Profile User', 'email' => '[email protected]']);+ $this->user->forceFill([+ 'pending_email' => '[email protected]',+ 'email_change_code' => '123456',+ 'email_change_code_expires_at' => now()->addMinutes(10),+ ])->save();++ $this->actingAs($this->user);+});++it('closes the email change modal after a successful verification', function () {+ Livewire::test(ProfileIndex::class)+ ->set('email_verification_code', '123456')+ ->call('verifyEmailChange')+ ->assertDispatched('success', 'Email address updated successfully.')+ ->assertDispatched('close-email-change-modal')+ ->assertSet('show_verification', false);++ expect($this->user->fresh()->email)->toBe('[email protected]');+});++it('keeps the email change modal open when the verification code is wrong', function () {+ Livewire::test(ProfileIndex::class)+ ->set('email_verification_code', '654321')+ ->call('verifyEmailChange')+ ->assertDispatched('error', 'Invalid or expired verification code.')+ ->assertNotDispatched('close-email-change-modal');++ expect($this->user->fresh()->email)->toBe('[email protected]');+});