From db069df32e29029e26602ac40e7cdfeb10a55b24 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 30 Mar 2016 17:58:32 +0200 Subject: Improve error messages for AAI upgrade form --- js/codeq/upgrade_to_aai.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'js') 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 . */ 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 . */ }) .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 . */ $('#disabled').css('display', 'none'); }, 'exit' : function(){ + jqMessages.hide(); jqNoBtn.off('click'); jqForm.off('submit'); jqLangSelect.off('click'); -- cgit v1.2.1