mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2026-01-28 07:43:18 +00:00
♻️ Update authentication buttons: replace `flux:navbar.item` and `flux:sidebar.item` with `flux:button` for improved UX and consistency. 🗑️ Update `.gitignore`: include additional configuration files (`.opencode`, `.switch-omo-config*`).
54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
use App\Support\NostrAuth;
|
|
use Livewire\Attributes\On;
|
|
use Livewire\Component;
|
|
|
|
new class extends Component
|
|
{
|
|
public bool $isLoggedIn = false;
|
|
|
|
public string $location = 'sidebar'; // 'sidebar' or 'navbar'
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->isLoggedIn = NostrAuth::check();
|
|
}
|
|
|
|
#[On('nostrLoggedIn')]
|
|
public function handleNostrLoggedIn(string $pubkey): void
|
|
{
|
|
NostrAuth::login($pubkey);
|
|
$this->js('window.location.reload(true);');
|
|
}
|
|
|
|
#[On('nostrLoggedOut')]
|
|
public function handleNostrLoggedOut(): void
|
|
{
|
|
$this->isLoggedIn = false;
|
|
}
|
|
}
|
|
?>
|
|
|
|
<div x-data="nostrLogin">
|
|
@if($isLoggedIn)
|
|
@if($location === 'sidebar')
|
|
<form method="post" action="{{ route('logout') }}">
|
|
@csrf
|
|
<flux:button variant="ghost" icon="arrow-right-start-on-rectangle" type="submit" wire:click="$dispatch('nostrLoggedOut')">Logout</flux:button>
|
|
</form>
|
|
@else
|
|
<form method="post" action="{{ route('logout') }}">
|
|
@csrf
|
|
<flux:button variant="ghost" icon="arrow-right-start-on-rectangle" type="submit" wire:click="$dispatch('nostrLoggedOut')">Logout</flux:button>
|
|
</form>
|
|
@endif
|
|
@else
|
|
@if($location === 'sidebar')
|
|
<flux:button variant="primary" icon="user" @click="openNostrLogin">Mit Nostr verbinden</flux:button>
|
|
@else
|
|
<flux:button variant="primary" icon="user" @click="openNostrLogin">Mit Nostr verbinden</flux:button>
|
|
@endif
|
|
@endif
|
|
</div>
|