diff options
Diffstat (limited to 'js/codeq')
-rw-r--r-- | js/codeq/upgrade_to_aai.js | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/js/codeq/upgrade_to_aai.js b/js/codeq/upgrade_to_aai.js index 867c9ea..88dd26d 100644 --- a/js/codeq/upgrade_to_aai.js +++ b/js/codeq/upgrade_to_aai.js @@ -24,12 +24,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ jqForm = $('#upgrade-to-aai-form'), jqNoBtn = $('#upgrade-to-aai-cancel'), jqPassword = $('#upgrade-to-aai-password'), - jqLangSelect = jqScreen.find('.lang-select'); + jqLangSelect = jqScreen.find('.lang-select'), + jqMessages = jqForm.find('.error,.success'); codeq.globalStateMachine.register('upgradeToAAI',{ 'jqScreen': jqScreen, - 'enter': function(){ + 'enter': function () { + jqMessages.hide(); + jqNoBtn.on('click',function(){ codeq.comms.samlLogin(false) .then(codeq.loginCallbackFunction) @@ -42,17 +45,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ }) .done(); }); - jqForm.on('submit',function(event) { - event.preventDefault(); // Prevent the form from submitting via the browser. + jqForm.on('submit', function (e) { + e.preventDefault(); + jqMessages.hide(); codeq.comms.samlLogin(true, jqPassword.val()) .then(function(data){ - // password does not match - if (data.code == 4) { - codeq.log.error('code: ' + data.code + ', message: ' + data.message); - alert('Password does not match. Enter right password or select No.'); + if (data.code == 4) { // incorrect password + jqForm.find('.error.wrong-password').show(); + } + else { // ok or other + codeq.loginCallbackFunction(data); } - //ok or other - else codeq.loginCallbackFunction(data); }) .fail(function(reason){ if(codeq.samlLogin){//if the user goes back to the normal login screen the timeout (which will happen) mustn't do anything @@ -75,6 +78,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ $('#disabled').css('display', 'none'); }, 'exit' : function(){ + jqMessages.hide(); jqNoBtn.off('click'); jqForm.off('submit'); jqLangSelect.off('click'); |