diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-03-30 17:58:32 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-03-30 17:58:32 +0200 |
commit | db069df32e29029e26602ac40e7cdfeb10a55b24 (patch) | |
tree | 759a4df00259f617ee67db538a107d8c7299dc84 | |
parent | 3fb0ac54a814dcc134f9f6299e37d5d71e452a05 (diff) |
Improve error messages for AAI upgrade form
-rw-r--r-- | index.html | 1 | ||||
-rw-r--r-- | js/codeq/upgrade_to_aai.js | 24 | ||||
-rw-r--r-- | res/en.json | 1 | ||||
-rw-r--r-- | res/sl.json | 1 |
4 files changed, 17 insertions, 10 deletions
@@ -281,6 +281,7 @@ <label class="sr-only" for="password" data-tkey="password">Password</label> <input type="password" class="form-control" name="password" id="upgrade-to-aai-password" data-tkey-placeholder="password" placeholder="Password" /> + <span class="error wrong-password" data-tkey="wrong_password" style="display: none;">Wrong password.</span> </div> <div data-tkey="upgrade_to_aai_body_text_2"> <p>Select <span class="badge">No</span> to do a separate account.</p> 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'); 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.", |