🔒 Add Nostr authentication support with custom guard and user provider

🛠️ Integrate Nostr auth across relevant components and views
📦 Update config, routes, and service provider for Nostr auth
This commit is contained in:
user
2025-11-20 23:10:20 +01:00
parent aff3f32c9b
commit 9c1cea5868
19 changed files with 419 additions and 6 deletions

View File

@@ -35,8 +35,34 @@ state([
form(\App\Livewire\Forms\ApplicationForm::class);
mount(function () {
if (\App\Support\NostrAuth::check()) {
$this->currentPubkey = \App\Support\NostrAuth::pubkey();
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()
->with([
'paymentEvents' => fn($query)
=> $query->where('year', date('Y')),
])
->where('pubkey', $this->currentPubkey)->first();
$this->email = $this->currentPleb->email;
$this->no = $this->currentPleb->no_email;
$this->showEmail = !$this->no;
if ($this->currentPleb->association_status === \App\Enums\AssociationStatus::ACTIVE) {
$this->amountToPay = config('app.env') === 'production' ? 21000 : 1;
}
if ($this->currentPleb->paymentEvents->count() < 1) {
$this->createPaymentEvent();
$this->currentPleb->load('paymentEvents');
}
$this->loadEvents();
$this->listenForPayment();
}
});
on([
'nostrLoggedIn' => function ($pubkey) {
\App\Support\NostrAuth::login($pubkey);
$this->currentPubkey = $pubkey;
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()
->with([
@@ -58,6 +84,8 @@ on([
$this->listenForPayment();
},
'nostrLoggedOut' => function () {
\App\Support\NostrAuth::logout();
$this->currentPubkey = null;
$this->currentPleb = null;
$this->yearsPaid = [];
@@ -422,8 +450,6 @@ $loadEvents = function () {
</div>
<div class="flex flex-wrap space-y-2 sm:space-y-0 items-center justify-between">
<x-button label="Mit Nostr verbinden" @click="openNostrLogin"
x-show="!$store.nostr.user"/>
{{-- https://v.nostr.build/bomfuwLnOTIDrP4y.mp4 --}}
<template x-if="$store.nostr.user">
<div class="flex items">