diff --git a/src/pages/RemoteLoginSuccess.tsx b/src/pages/RemoteLoginSuccess.tsx index 4419a5b..e8802a5 100644 --- a/src/pages/RemoteLoginSuccess.tsx +++ b/src/pages/RemoteLoginSuccess.tsx @@ -3,8 +3,8 @@ import { useNavigate } from 'react-router-dom'; import { useNostrLogin } from '@nostrify/react/login'; import { Loader2, CheckCircle, XCircle } from 'lucide-react'; -// Storage key used by @nostrify/react for logins -const LOGINS_STORAGE_KEY = 'nostrify:logins'; +// Storage key must match the one in App.tsx NostrLoginProvider +const LOGINS_STORAGE_KEY = 'nostr:login'; export function RemoteLoginSuccess() { const navigate = useNavigate(); @@ -33,7 +33,11 @@ export function RemoteLoginSuccess() { if (isLoggedIn) { setStatus('success'); const timer = setTimeout(() => { - navigate('/', { replace: true }); + // Try to close this tab (works if opened by signer app) + // This leaves the user on the original tab which should detect the login + window.close(); + // If we're still here (close didn't work), do a full page redirect + window.location.href = '/'; }, 1500); return () => clearTimeout(timer); } @@ -57,7 +61,10 @@ export function RemoteLoginSuccess() { const parsed = JSON.parse(e.newValue); if (Array.isArray(parsed) && parsed.length > 0) { setStatus('success'); - setTimeout(() => navigate('/', { replace: true }), 1500); + setTimeout(() => { + window.close(); + window.location.href = '/'; + }, 1500); } } catch { // Ignore parse errors @@ -67,7 +74,7 @@ export function RemoteLoginSuccess() { window.addEventListener('storage', handleStorage); return () => window.removeEventListener('storage', handleStorage); - }, [navigate]); + }, []); return (