Errors should reflect only a result of last operation.

https://fedorahosted.org/freeipa/ticket/4470

Fixes issue found by Endi:

Try logging in with an incorrect password/OTP. After you get a login
error click Sync OTP Token. Once the sync is completed it will go
back to the login page with a "Token was synchronized" message that
disappears in a few seconds, but the old login error still appears
which is confusing. Error messages in the UI should only reflect the
last executed operation.
--
Petr Vobornik
From 789a8a2fd5ad42510e5bc08251f877d4f7445924 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Fri, 22 Aug 2014 13:47:11 +0200
Subject: [PATCH] webui: do not show login error when switching back from otp
 sync screen

Errors should reflect only a result of last operation.

https://fedorahosted.org/freeipa/ticket/4470
---
 install/ui/src/freeipa/widget.js              | 27 +++++++++++++++++++++++----
 install/ui/src/freeipa/widgets/LoginScreen.js |  1 +
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index 4bdf273dbb9cd8e379aa7a28802e5b32e0bc7762..84afac0216e943663c871b2994cd832fc99eb1b7 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -5677,7 +5677,8 @@ exp.alert_helper = IPA.alert_helper = {
             name: name,
             text: text,
             cls: 'alert alert-danger',
-            icon: 'fa fa-exclamation-circle'
+            icon: 'fa fa-exclamation-circle',
+            type: 'error'
         };
     },
 
@@ -5692,7 +5693,8 @@ exp.alert_helper = IPA.alert_helper = {
             name: name,
             text: text,
             cls: 'alert alert-warning',
-            icon: 'fa fa-warning'
+            icon: 'fa fa-warning',
+            type: 'warning'
         };
     },
 
@@ -5707,7 +5709,8 @@ exp.alert_helper = IPA.alert_helper = {
             name: name,
             text: text,
             cls: 'alert alert-info',
-            icon: 'fa fa-info-circle'
+            icon: 'fa fa-info-circle',
+            type: 'info'
         };
     },
 
@@ -5722,7 +5725,8 @@ exp.alert_helper = IPA.alert_helper = {
             name: name,
             text: text,
             cls: 'alert alert-success',
-            icon: 'fa fa-check-circle-o'
+            icon: 'fa fa-check-circle-o',
+            type: 'success'
         };
     },
 
@@ -5818,6 +5822,21 @@ exp.validation_summary_widget = IPA.validation_summary_widget = function(spec) {
         that.render_items();
     };
 
+    that.remove_all = function(type) {
+
+        if (!type) that.items.empty();
+
+        for (var i=0, l=that.items.length; i<l; i++) {
+            var alert = that.items.get_value_by_index(i);
+            if (alert.type !== type) continue;
+            that.items.remove(alert.name);
+            i--;
+            l--;
+        }
+
+        that.render_items();
+    };
+
     return that;
 };
 
diff --git a/install/ui/src/freeipa/widgets/LoginScreen.js b/install/ui/src/freeipa/widgets/LoginScreen.js
index 2c5002016f9f70802c52aa905c71a48eaf76ce7f..fb7ccccc6c34d9c1c7115dd95809f3a39de488eb 100644
--- a/install/ui/src/freeipa/widgets/LoginScreen.js
+++ b/install/ui/src/freeipa/widgets/LoginScreen.js
@@ -170,6 +170,7 @@ define(['dojo/_base/declare',
 
         on_sync: function() {
             var user = this.get_field('username').get_value()[0];
+            this.get_widget('validation').remove_all('error');
             this.emit('require-otp-sync', { source: this, user: user });
         },
 
-- 
1.9.3

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to