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 --- index.html | 1 + js/codeq/upgrade_to_aai.js | 24 ++++++++++++++---------- res/en.json | 1 + res/sl.json | 1 + 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 43fca9e..8e4eec1 100644 --- a/index.html +++ b/index.html @@ -281,6 +281,7 @@ +

Select No to do a separate account.

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'); diff --git a/res/en.json b/res/en.json index 2c6559b..c47eac8 100644 --- a/res/en.json +++ b/res/en.json @@ -4,6 +4,7 @@ "connection_failed": "Could not connect to server.", "language": "Language", "ui_language_title": "Select the UI language.", + "wrong_password": "Wrong password.", "wrong_username_or_password": "Wrong username or password.", "password_change_failed": "Password change failed.", "password_changed": "Password changed.", diff --git a/res/sl.json b/res/sl.json index 18e2e86..f1f4c06 100644 --- a/res/sl.json +++ b/res/sl.json @@ -4,6 +4,7 @@ "connection_failed": "Povezava na strežnik ni uspela.", "language": "Jezik", "ui_language_title": "Izberi jezik uporabniškega vmesnika.", + "wrong_password": "Napačno geslo.", "wrong_username_or_password": "Napačno uporabniško ime ali geslo.", "password_change_failed": "Sprememba gesla ni uspela.", "password_changed": "Geslo spremenjeno.", -- cgit v1.2.1