🔒 Fix conditional checks in Livewire Profile to prevent null errors for users without association records

- Updated Blade conditionals to verify `$currentPleb` exists before accessing its properties.
- Added test case to ensure `Profile` renders correctly for logged-in pubkeys without associated pleb records.
This commit is contained in:
HolgerHatGarKeineNode
2026-06-17 10:02:14 +02:00
parent 5f28bfedd4
commit d07d2b3fba
2 changed files with 11 additions and 2 deletions
@@ -1191,7 +1191,7 @@ new class extends Component {
</div>
</template>
@if($currentPubkey && $currentPleb->association_status->value < 2)
@if($currentPubkey && $currentPleb && $currentPleb->association_status->value < 2)
<flux:card class="mt-4">
<div class="flex items-start gap-3">
<svg class="shrink-0 fill-current text-green-500 mt-0.5" width="16" height="16"
@@ -1208,7 +1208,7 @@ new class extends Component {
</div>
@endif
@if($currentPubkey && !$currentPleb->application_for && $currentPleb->association_status->value < 2)
@if($currentPubkey && $currentPleb && !$currentPleb->application_for && $currentPleb->association_status->value < 2)
<!-- Membership Registration Section -->
<div class="space-y-4 py-6">
<div>
@@ -60,6 +60,15 @@ it('clears state on nostr logout', function () {
->assertSet('currentPleb', null);
});
it('renders without error for a logged-in pubkey that has no pleb record', function () {
NostrAuth::login(str_repeat('a', 64));
Livewire::test('association.profile')
->assertSet('currentPubkey', str_repeat('a', 64))
->assertSet('currentPleb', null)
->assertStatus(200);
});
it('can save email address', function () {
$pleb = EinundzwanzigPleb::factory()->create();