**Nostr Login:** Prevented session race conditions during login flow.

- 🛡️ Added `nostrLoginInProgress` flag to pause `wire:poll` during Nostr login round-trip.
- 🔄 Removed redundant `Session::regenerate()` to avoid session ID conflicts.
- 🪲 Improved error handling for signature serialization and Nostr signer unavailability.
This commit is contained in:
BT
2026-05-04 00:36:00 +02:00
parent dc723855df
commit 686be7e8f7
2 changed files with 71 additions and 39 deletions
+10 -2
View File
@@ -291,8 +291,10 @@ class extends Component {
if ($loginKey) {
$user = User::find($loginKey->user_id);
// auth()->login() already migrates the session id (rotates cookie).
// An additional Session::regenerate() races with the in-flight
// wire:poll request and produces 419s on the next round-trip.
auth()->login($user);
Session::regenerate();
session([
'lang_country' => $this->currentLangCountry,
]);
@@ -424,5 +426,11 @@ class extends Component {
</div>
</div>
<div wire:poll.4s="checkAuth" wire:key="checkAuth"></div>
{{-- Pause Livewire polling while a Nostr signature round-trip is in
flight. Otherwise wire:poll can fire a parallel /livewire/update
request that races with auth()->login()'s session migration and
lands on an invalidated session id, producing 419 TokenMismatch. --}}
<template x-if="!nostrLoginInProgress">
<div wire:poll.4s="checkAuth" wire:key="checkAuth"></div>
</template>
</div>