From 686be7e8f788bfecdd947f5ca049b9bbd0522583 Mon Sep 17 00:00:00 2001 From: BT Date: Mon, 4 May 2026 00:36:00 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20**Nostr=20Login:**=20Prevented=20se?= =?UTF-8?q?ssion=20race=20conditions=20during=20login=20flow.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 🛡️ 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. --- resources/js/nostrLogin.js | 98 ++++++++++++------- resources/views/livewire/auth/login.blade.php | 12 ++- 2 files changed, 71 insertions(+), 39 deletions(-) diff --git a/resources/js/nostrLogin.js b/resources/js/nostrLogin.js index 88d7563..7b6c15d 100644 --- a/resources/js/nostrLogin.js +++ b/resources/js/nostrLogin.js @@ -5,6 +5,11 @@ export default () => ({ startTime: null, pollCount: 0, MAX_POLL_COUNT: 30, + // Toggled while window.nostr.signEvent is awaiting the wallet so we can + // pause wire:poll, preventing it from racing with auth()->login()'s + // session-id migration (which would otherwise yield a 419 on the next + // round-trip). + nostrLoginInProgress: false, async init() { this.startTime = Date.now(); @@ -42,47 +47,66 @@ export default () => ({ }, async openNostrLogin() { - const challenge = await this.resolveChallenge(); + // Flip the flag immediately so the wire:poll