diff options
Diffstat (limited to 'js/codeq')
-rw-r--r-- | js/codeq/aaiLogin.js | 34 | ||||
-rw-r--r-- | js/codeq/comms.js | 4 |
2 files changed, 36 insertions, 2 deletions
diff --git a/js/codeq/aaiLogin.js b/js/codeq/aaiLogin.js index e6e36ab..fe7bfc8 100644 --- a/js/codeq/aaiLogin.js +++ b/js/codeq/aaiLogin.js @@ -5,26 +5,56 @@ var jqNavBarRight = $('.nav.navbar-nav.navbar-right'), jqNavigationHomeBtn = $('#navigation-home'), - jqCancelAaiLogin = $("#cancel_aai_login"); + jqCancelAaiLogin = $("#cancel_aai_login"), + jqDisabledOverlay = $('#disabled'), + jqAaiIframe = $('#aai_iframe'), + baseSamlUrl = 'https://codeq.si/Shibboleth.sso/Login?sid=', + samlLoginUrl = ''; codeq.globalStateMachine.register('aailogin',{ 'enter': function(){ + jqDisabledOverlay.css('display', ''); + jqNavigationHomeBtn.off('click');//remove the click listener of this element here jqNavBarRight.css('display','none');//hide settings etc. + //enable the back button jqCancelAaiLogin.on('click',function(){ codeq.globalStateMachine.transition('login'); }); $('#signed-in-title').html(''); $('#screen_aai_login').css('display',''); + + codeq.comms.connect() + .then(function(){ + samlLoginUrl = baseSamlUrl + codeq.comms.getSid(); + 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'); + }) + .fail(function(reason){ + codeq.log.error('SAML login failed: ' + reason); + alert('SAML login failed: ' + reason); + }) + .done(); + + jqDisabledOverlay.css('display','none'); }, 'exit' : function(){ //disable site specific listeners + codeq.comms.off('saml_login'); + jqAaiIframe.attr('src','');//lets remove the url jqCancelAaiLogin.off('click'); + samlLoginUrl = ''; $("#screen_aai_login").css('display', 'none'); - //re-enable the click listener + + //re-enable the click listener of the logo jqNavigationHomeBtn.on('click', function(e){ codeq.globalStateMachine.transition('language'); e.preventDefault(); diff --git a/js/codeq/comms.js b/js/codeq/comms.js index e12ffa3..225026b 100644 --- a/js/codeq/comms.js +++ b/js/codeq/comms.js @@ -524,6 +524,10 @@ 'getResourceTree': function () { return ajaxGet(ajaxDataPrefix + 'resources.json'); + }, + + 'samlLogin': function(){ + return this.send({'action':'saml_login'}); } }; })(); |