From feb87a34e3b195d7c204f5d017e108f4f46498e0 Mon Sep 17 00:00:00 2001 From: Robert Zorko Date: Thu, 15 Oct 2015 14:41:34 +0200 Subject: added the web logic for the saml login, but it still needs testing --- js/codeq/aaiLogin.js | 32 ++++++++++++++++++++++++++++++-- js/codeq/comms.js | 4 ++++ 2 files changed, 34 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/codeq/aaiLogin.js b/js/codeq/aaiLogin.js index e6e36ab..6ea49ea 100644 --- a/js/codeq/aaiLogin.js +++ b/js/codeq/aaiLogin.js @@ -5,26 +5,54 @@ 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', ''); + + samlLoginUrl = baseSamlUrl + codeq.comms.getSid(); + jqAaiIframe.attr('src', samlLoginUrl); + 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.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'}); } }; })(); -- cgit v1.2.1