diff options
author | Marko Pušnik <marko.pusnik@guru.si> | 2015-10-15 18:46:20 +0200 |
---|---|---|
committer | Marko Pušnik <marko.pusnik@guru.si> | 2015-10-15 18:46:20 +0200 |
commit | 650357aedf68b04a1844de34367f9b2ff397b436 (patch) | |
tree | bc7261f4ca524bc0e96835e09494c08e44267c57 /js | |
parent | 70787b8efa9a777e37989d1c0dfad3ade21e128e (diff) | |
parent | 059e165e3f97923f7e05c75b0162271f761982cb (diff) |
Merge branch 'master' of ssh://212.235.189.51:22122/codeq-web
Diffstat (limited to 'js')
-rw-r--r-- | js/codeq/aaiLogin.js | 6 | ||||
-rw-r--r-- | js/codeq/comms.js | 2 | ||||
-rw-r--r-- | js/codeq/core.js | 4 | ||||
-rw-r--r-- | js/codeq/login.js | 53 |
4 files changed, 34 insertions, 31 deletions
diff --git a/js/codeq/aaiLogin.js b/js/codeq/aaiLogin.js index fe7bfc8..74a9ee4 100644 --- a/js/codeq/aaiLogin.js +++ b/js/codeq/aaiLogin.js @@ -32,11 +32,7 @@ jqAaiIframe.attr('src', samlLoginUrl); return codeq.comms.samlLogin(); }) - .then(function(data){ - codeq.log.debug(JSON.stringify(data)); - if(data.code !== 0) throw new Error('SAML login failed, code: ' + data.code + ', message: ' + data.message); - codeq.globalStateMachine.transition('language'); - }) + .then(codeq.loginCallbackFunction) .fail(function(reason){ codeq.log.error('SAML login failed: ' + reason); alert('SAML login failed: ' + reason); diff --git a/js/codeq/comms.js b/js/codeq/comms.js index 225026b..5908e0d 100644 --- a/js/codeq/comms.js +++ b/js/codeq/comms.js @@ -527,7 +527,7 @@ }, 'samlLogin': function(){ - return this.send({'action':'saml_login'}); + return this.send({'action':'saml_login','gui_lang':codeq.getLang()}); } }; })(); diff --git a/js/codeq/core.js b/js/codeq/core.js index 33c00a4..6d3a5dc 100644 --- a/js/codeq/core.js +++ b/js/codeq/core.js @@ -392,6 +392,10 @@ codeq.fire('langchange', {'lang': newLang}); }, + 'getLang': function(){ + return codeq.settings['gui_lang']; + }, + 'setResources': function (newResources) { resources = newResources; }, diff --git a/js/codeq/login.js b/js/codeq/login.js index 97bb44b..48c13b2 100644 --- a/js/codeq/login.js +++ b/js/codeq/login.js @@ -9,6 +9,33 @@ jqSignupBtn = $('#signup_button'), jqSubmitLoginBtn = $("#submit"); + //the loginCallbackFunction is used here and in the AAI login as well + codeq.loginCallbackFunction = function (data) { + $('#disabled').css('display', 'none'); + $('#disabled').css('cursor', ''); + if (data.code !== 0) throw new Error('Login failed, code: ' + data.code + ', message: ' + data.message); + + //nav signed in... + $('#signed-in-title').html(data.name||$('#username').val()); + //merge with profile page + $('#profileUsername').html($('#username').val()); + $('#profileName').html(data.name||'undefined'); + $('#profileJoined').html(new Date(data.joined).toLocaleString()); + $('#profileLastLogin').html(new Date(data["last-login"]).toLocaleString()); + + //merge these settings into the already existing default settings + var sett = data.settings; + $.extend(codeq.settings, sett); + if('gui_lang' in sett && sett['gui_lang'] in codeq.supportedLangs){ + codeq.setLang(sett['gui_lang']); + $("#gui_lang_select").val(sett['gui_lang']); + } + $('#robot_address_input').val(codeq.settings['robot_address'] || ''); + + codeq.globalStateMachine.transition('language'); + //codeq.activateState('language'); + }; + var loginFun = function(){ $('#disabled').css('display', ''); $('#disabled').css('cursor', 'wait'); @@ -16,31 +43,7 @@ .then(function () { return codeq.comms.login($('#username').val(), $('#password').val()); }) - .then(function (data) { - $('#disabled').css('display', 'none'); - $('#disabled').css('cursor', ''); - if (data.code !== 0) throw new Error('Login failed, code: ' + data.code + ', message: ' + data.message); - - //nav signed in... - $('#signed-in-title').html(data.name||$('#username').val()); - //merge with profile page - $('#profileUsername').html($('#username').val()); - $('#profileName').html(data.name||'undefined'); - $('#profileJoined').html(new Date(data.joined).toLocaleString()); - $('#profileLastLogin').html(new Date(data["last-login"]).toLocaleString()); - - //merge these settings into the already existing default settings - var sett = data.settings; - $.extend(codeq.settings, sett); - if('gui_lang' in sett && sett['gui_lang'] in codeq.supportedLangs){ - codeq.setLang(sett['gui_lang']); - $("#gui_lang_select").val(sett['gui_lang']); - } - $('#robot_address_input').val(codeq.settings['robot_address'] || ''); - - codeq.globalStateMachine.transition('language'); - //codeq.activateState('language'); - }) + .then(codeq.loginCallbackFunction) .fail(function (reason) { $('#disabled').css('display', 'none'); $('#disabled').css('cursor', ''); |