summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2016-03-30 17:58:32 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2016-03-30 17:58:32 +0200
commitdb069df32e29029e26602ac40e7cdfeb10a55b24 (patch)
tree759a4df00259f617ee67db538a107d8c7299dc84 /js
parent3fb0ac54a814dcc134f9f6299e37d5d71e452a05 (diff)
Improve error messages for AAI upgrade form
Diffstat (limited to 'js')
-rw-r--r--js/codeq/upgrade_to_aai.js24
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');