diff --git a/mar/phaser/mar.js b/mar/phaser/mar.js index 406ff2e..2eeb37c 100644 --- a/mar/phaser/mar.js +++ b/mar/phaser/mar.js @@ -791,18 +791,6 @@ function manhanttanDistance(x1, y1, x2, y2) { } function codeListener(message) { - - if (message.t === "code") { - - ace.edit("editor").setValue(message.code); - - } -} - -/** - * Listens for authentications responses from the server - */ -function authListener(message) { if (message.t === "code") { var code = message.code; if(typeof window.localStorage !== 'undefined') { // localStorage is supported @@ -816,6 +804,22 @@ function authListener(message) { } } +/** + * Listens for authentications responses from the server + */ +function authListener(message) { + if (message.t === "auth") { + + if (message.m === "ok") { + console.log("Auth successful"); + mar.client.requestUserInfo(); + + } else { + alert("Authentication failed. Please make sure you are logged in and reload the page."); + } + } +} + function codeResponseListener(message) { if (message.t === "codeResponse") {