From a73d33a821ac08d2825ee7074859db7ad806e319 Mon Sep 17 00:00:00 2001 From: Benjamin Oezcan Date: Thu, 19 Nov 2026 02:17:54 +0100 Subject: [PATCH] fix(net): expired or stale session while online asks to log in again --- game/game.js | 14 +++++++++++++- game/lang.js | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/game/game.js b/game/game.js index 6b3b690..71fc5e3 100644 --- a/game/game.js +++ b/game/game.js @@ -1926,7 +1926,19 @@ } setMode('online'); // every page load starts in online play accounts.resume(); - if (net && net.enabled) { net.auth.resume(); net.auth.onChange(() => { hud(); refreshDev(); if (mode === 'title') showTitle(); }); } + if (net && net.enabled) { + let lastUid = null; + net.auth.onChange(cur => { + hud(); refreshDev(); + // session gone while playing online (expired / server reset / logged out elsewhere): ask to log in again + if (lastUid && !cur && gameMode === 'online' && save && ['garage', 'lobby', 'result'].includes(mode)) { + if (lobby) lobby.leave(); + showOnlineLogin(false, 'SESSION_EXPIRED', 'online'); + } else if (mode === 'title') showTitle(); + lastUid = cur ? cur.uid : null; + }); + if (net.auth.resume()) lastUid = net.uid; + } hud(); if (!hostOk()) { card(`

Robot Clash

${t('wrong_host')}

${CREDITS}

`); diff --git a/game/lang.js b/game/lang.js index a7ca6c9..d45a777 100644 --- a/game/lang.js +++ b/game/lang.js @@ -246,7 +246,7 @@ window.LANG = { e_INVALID_LOGIN: 'Wrong name or password.', e_NAME_EXISTS: 'That name is already taken.', e_BAD_NAME: 'The name needs at least 3 letters or digits.', e_RATE_LIMIT: 'Too many tries - please wait a minute.', e_INVALID_ROBOT: 'Your robot is not ready to fight - check weight and power in the workshop.', e_OPPONENT_INVALID: 'The other robot is not ready to fight.', e_BUSY: 'That player is busy right now.', e_NOT_AVAILABLE: 'That player is not available.', - e_OUTDATED: 'A new version is out - please reload the page.', e_REPLACED: 'You are now playing in another window.', + e_OUTDATED: 'A new version is out - please reload the page.', e_REPLACED: 'You are now playing in another window.', e_SESSION_EXPIRED: 'Your session has ended - please log in again.', net_connecting: 'Connecting to the server...', net_lost: 'Connection lost', match_lost: 'No word from the server - the fight is counted there. Back to the lobby.', pt_open: '🎨 Paint it yourself', pt_title: 'Paint booth', pt_top: 'TOP VIEW · front', pt_side: 'SIDE · front', pt_view_top: 'Top', pt_view_right: 'Right', pt_view_left: 'Left', pt_view_front: 'Front', pt_view_free: 'Turn', @@ -526,7 +526,7 @@ window.LANG = { e_INVALID_LOGIN: 'Name oder Passwort falsch.', e_NAME_EXISTS: 'Dieser Name ist schon vergeben.', e_BAD_NAME: 'Der Name braucht mindestens 3 Buchstaben oder Ziffern.', e_RATE_LIMIT: 'Zu viele Versuche - bitte eine Minute warten.', e_INVALID_ROBOT: 'Dein Roboter ist nicht kampfbereit - prüfe Gewicht und Strom in der Werkstatt.', e_OPPONENT_INVALID: 'Der andere Roboter ist nicht kampfbereit.', e_BUSY: 'Dieser Spieler ist gerade beschäftigt.', e_NOT_AVAILABLE: 'Dieser Spieler ist nicht verfügbar.', - e_OUTDATED: 'Es gibt eine neue Version - bitte die Seite neu laden.', e_REPLACED: 'Du spielst jetzt in einem anderen Fenster.', + e_OUTDATED: 'Es gibt eine neue Version - bitte die Seite neu laden.', e_REPLACED: 'Du spielst jetzt in einem anderen Fenster.', e_SESSION_EXPIRED: 'Deine Sitzung ist abgelaufen - bitte neu anmelden.', net_connecting: 'Verbinde mit dem Server...', net_lost: 'Verbindung verloren', match_lost: 'Keine Antwort vom Server - der Kampf wird dort gewertet. Zurück zur Lobby.', pt_open: '🎨 Selbst bemalen', pt_title: 'Lackiererei', pt_top: 'OBEN · vorne', pt_side: 'SEITE · vorne', pt_view_top: 'Oben', pt_view_right: 'Rechts', pt_view_left: 'Links', pt_view_front: 'Vorne', pt_view_free: 'Drehen',