From ae39a505784603c6e918c4234eee9cb7f85811e2 Mon Sep 17 00:00:00 2001 From: Robert Zorko Date: Thu, 17 Dec 2015 14:48:05 +0100 Subject: fixed the session expired bug --- js/codeq/comms.js | 14 ++++++++++---- js/codeq/core.js | 2 +- js/codeq/prolog.js | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/js/codeq/comms.js b/js/codeq/comms.js index fcce6df..d3f9252 100644 --- a/js/codeq/comms.js +++ b/js/codeq/comms.js @@ -114,6 +114,7 @@ along with this program. If not, see . */ // * the user logged in elsewhere s = 'The server forced us to disconnect'; if (typeof m.message === 'string') s += ': ' + m.message; + sid = null; codeq.reset(s); return; @@ -345,7 +346,7 @@ along with this program. If not, see . */ // reject any outstanding promises for (tid in waiters) { if (waiters.hasOwnProperty(tid)) { - waiters[id].promise.reject(new Error(reason || 'Forced disconnect')); + waiters[tid].promise.reject(new Error(reason || 'Forced disconnect')); delete waiters[tid]; } } @@ -387,9 +388,14 @@ along with this program. If not, see . */ }, 'logout': function () { - var promise = this.send({'action': 'logout'}); - sid = null; - return promise; + var performLogout = function() { + var promise = codeq.comms.send({'action': 'logout'}); + sid = null; + return promise; + }; + + if (socket) return performLogout(); + return this.connect().then(performLogout); }, 'signup': function (username, name, email, password) { diff --git a/js/codeq/core.js b/js/codeq/core.js index 84331d4..e86b396 100644 --- a/js/codeq/core.js +++ b/js/codeq/core.js @@ -612,7 +612,7 @@ along with this program. If not, see . */ }, // reset the app - 'reset': function (reason) { + reset: function (reason) { codeq.log.info('App reset: ' + (reason || 'no reason given')); codeq.globalStateMachine.transition('login'); codeq.wait( diff --git a/js/codeq/prolog.js b/js/codeq/prolog.js index 7ff0af6..e35984a 100644 --- a/js/codeq/prolog.js +++ b/js/codeq/prolog.js @@ -250,7 +250,7 @@ along with this program. If not, see . */ codeq.tr.registerDictionary('prolog', codeq.tr.emptyDictionary); // to make the translator happy, when this screen is not active }); - createPrologHandler = function (problemDef, commonDef, currentSolution) { + var createPrologHandler = function (problemDef, commonDef, currentSolution) { var jqDescriptionContent = jqDescription.find('.description'), jqEditor = jqCode.find('.code_editor'), jqTerminal = jqConsole.find('.console'), -- cgit v1.2.1