From 8fb284f8ed396580c71710fe75cadb899a73f035 Mon Sep 17 00:00:00 2001 From: jwinterm Date: Sat, 18 Jul 2026 04:37:53 -0400 Subject: [PATCH] fix(smirk): re-check link status after token rotation (fixes one-click after reload) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even with the anon_token status query, Smirk one-click stayed disabled after a reload: the server ROTATES the session token on every resume (sessionManager), so the initial SmirkAuth.checkStatus() raced the rotation and 403d with the now-stale token, leaving _isLinked=false. Re-run checkStatus right after the fresh token is persisted (session_token / session_resumed) via _refreshSmirkLinked, so _isLinked reflects the current token before the user buys — restoring the Smirk payment popup. --- html/js/network/socketHandlers.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/html/js/network/socketHandlers.js b/html/js/network/socketHandlers.js index 9df9868..25907fa 100644 --- a/html/js/network/socketHandlers.js +++ b/html/js/network/socketHandlers.js @@ -236,6 +236,17 @@ const SocketHandlers = { UI.scrollChat(); // New session = no address set yet SocketHandlers._updateAddressButtonStatus(false); + SocketHandlers._refreshSmirkLinked(); + } + }, + + // The server ROTATES the session token on every resume, so the initial SmirkAuth.checkStatus() + // races the rotation and 403's with the stale token — leaving _isLinked=false and disabling + // one-click Smirk payment after a reload. Re-check with the FRESH token once it's stored. + _refreshSmirkLinked: function() { + if (typeof SmirkAuth !== 'undefined' && SmirkAuth.checkStatus && + SmirkAuth.isAvailable && SmirkAuth.isAvailable()) { + try { SmirkAuth.checkStatus(); } catch (e) { /* non-critical */ } } }, @@ -244,6 +255,7 @@ const SocketHandlers = { try { localStorage.setItem('wownerogue_token', data.token); } catch(e) {} $('#messages').append($('
  • ').text('Session resumed.')); UI.scrollChat(); + SocketHandlers._refreshSmirkLinked(); } if (data && typeof data.credits === 'number') { SocketHandlers._updateCreditsDisplay(data.credits);