fix(smirk): re-check link status after token rotation (fixes one-click after reload)

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.
This commit is contained in:
jwinterm
2026-07-18 04:37:53 -04:00
parent 8c36f40efc
commit 8fb284f8ed
+12
View File
@@ -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($('<li class="status">').text('Session resumed.'));
UI.scrollChat();
SocketHandlers._refreshSmirkLinked();
}
if (data && typeof data.credits === 'number') {
SocketHandlers._updateCreditsDisplay(data.credits);