diff --git a/app/Livewire/Forms/ProfileForm.php b/app/Livewire/Forms/ProfileForm.php index e27dfba..df413f6 100644 --- a/app/Livewire/Forms/ProfileForm.php +++ b/app/Livewire/Forms/ProfileForm.php @@ -17,6 +17,20 @@ class ProfileForm extends Form public ?EinundzwanzigPleb $currentPleb; + public function updatingEmail(mixed $value): void + { + if (! is_string($value) && ! is_null($value)) { + abort(422); + } + } + + public function updatingNip05Handle(mixed $value): void + { + if (! is_string($value) && ! is_null($value)) { + abort(422); + } + } + public function setEmail(EinundzwanzigPleb $currentPleb): void { $this->currentPleb = $currentPleb; diff --git a/resources/views/livewire/association/profile.blade.php b/resources/views/livewire/association/profile.blade.php index c289f2c..910d49e 100644 --- a/resources/views/livewire/association/profile.blade.php +++ b/resources/views/livewire/association/profile.blade.php @@ -147,6 +147,15 @@ new class extends Component { ]); } + public function updatingFax(mixed $value): void + { + if (! is_string($value)) { + $this->skipRender(); + + abort(422); + } + } + public function updatedFax(): void { $this->js('alert("Markus Turm wird sich per Fax melden!")'); diff --git a/tests/Feature/Livewire/Association/ProfileTest.php b/tests/Feature/Livewire/Association/ProfileTest.php index 35665ad..7bf7258 100644 --- a/tests/Feature/Livewire/Association/ProfileTest.php +++ b/tests/Feature/Livewire/Association/ProfileTest.php @@ -6,6 +6,24 @@ use App\Support\NostrAuth; use Illuminate\Support\Facades\Http; use Livewire\Livewire; +it('rejects non-string values for the fax field', function () { + Livewire::test('association.profile') + ->set('fax', []) + ->assertStatus(422); +}); + +it('rejects non-string values for the email field', function () { + Livewire::test('association.profile') + ->set('profileForm.email', []) + ->assertStatus(422); +}); + +it('rejects non-string values for the nip05Handle field', function () { + Livewire::test('association.profile') + ->set('profileForm.nip05Handle', []) + ->assertStatus(422); +}); + it('handles nostr login correctly', function () { $pleb = EinundzwanzigPleb::factory()->create();