diff options
author | Robert Zorko <robertz@gurucue.com> | 2015-12-17 14:48:05 +0100 |
---|---|---|
committer | Robert Zorko <robertz@gurucue.com> | 2015-12-17 14:48:05 +0100 |
commit | ae39a505784603c6e918c4234eee9cb7f85811e2 (patch) | |
tree | b8694c1ec5ddf9f2bd190108af33f9be5e5ff8d7 /js/codeq | |
parent | 27d9966693bc88495617ba165f290c7f2e54abd0 (diff) |
fixed the session expired bug
Diffstat (limited to 'js/codeq')
-rw-r--r-- | js/codeq/comms.js | 14 | ||||
-rw-r--r-- | js/codeq/core.js | 2 | ||||
-rw-r--r-- | 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 <http://www.gnu.org/licenses/>. */ // * 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 <http://www.gnu.org/licenses/>. */ // 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 <http://www.gnu.org/licenses/>. */ }, '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 <http://www.gnu.org/licenses/>. */ }, // 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 <http://www.gnu.org/licenses/>. */ 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'), |