Greg Sheremeta has uploaded a new change for review.

Change subject: userportal, webadmin: allow SSO robots to fill in the login form
......................................................................

userportal, webadmin: allow SSO robots to fill in the login form

Our UI editors/models don't get populated from forms unless a change event 
fires on
the form (usually on blur when a user types in a value and tabs away from that 
field
(ValueChangeEvent)).

For the login form, there are third-party SSO applications that "paste" 
credentials
into the form. LastPass, for example, works fine because it fires a DOM change 
event
on the fields it pastes into. But here are other solutions that don't fire that
change event after pasting into the fields.

We want to allow those to work by forcing change events on the form fields
when the form is submitted. This patch does just that. Now when the login form
is submitted, "change" is fired on the username, password, and profile fields, 
which
causes the editor and model to be properly populated, which allows the login to
succeed.

Change-Id: I0364ac5c4524f5260480bca38642a6998d0c9147
Bug-Url: https://bugzilla.redhat.com/1154666
Signed-off-by: Greg Sheremeta <[email protected]>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/presenter/AbstractLoginPresenterWidget.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/view/AbstractLoginFormView.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/AbstractValidatedWidgetWithLabel.java
3 files changed, 47 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/17/38017/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/presenter/AbstractLoginPresenterWidget.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/presenter/AbstractLoginPresenterWidget.java
index a94f11a..02a5400 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/presenter/AbstractLoginPresenterWidget.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/presenter/AbstractLoginPresenterWidget.java
@@ -51,6 +51,10 @@
         HasKeyPressHandlers getLoginForm();
 
         String getMotdAnchorHtml(String url);
+
+        T flush();
+
+        void fireChangeEventsOnFields();
     }
 
     private static final Logger logger = 
Logger.getLogger(AbstractLoginPresenterWidget.class.getName());
@@ -106,6 +110,9 @@
         registerHandler(getView().getLoginButton().addClickHandler(new 
ClickHandler() {
             @Override
             public void onClick(ClickEvent event) {
+                // force fire change events in case the login form was filled 
in by an SSO robot or pasted in
+                getView().fireChangeEventsOnFields();
+                getView().flush();
                 modelCommandInvoker.invokeDefaultCommand();
             }
         }));
@@ -114,6 +121,9 @@
             @Override
             public void onKeyPress(KeyPressEvent event) {
                 if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) 
{
+                    // force fire change events in case the login form was 
filled in by an SSO robot or pasted in
+                    getView().fireChangeEventsOnFields();
+                    getView().flush();
                     modelCommandInvoker.invokeDefaultCommand();
                 }
             }
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/view/AbstractLoginFormView.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/view/AbstractLoginFormView.java
index c5acf64..239e7c8 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/view/AbstractLoginFormView.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/view/AbstractLoginFormView.java
@@ -197,4 +197,24 @@
         return loginForm;
     }
 
+    /**
+     * <p>
+     * Force fire change events on the login form fields.
+     * </p>
+     * <p>
+     * Our editors/models don't get populated from forms unless a change event 
fires on the form
+     * (usually on blur when a user types in a value and tabs away).
+     * </p>
+     * <p>
+     * For the login form, there are third-party SSO applications that "paste" 
credentials
+     * into the form. We want to allow those to work by forcing change events 
on the form
+     * when the form is submitted.
+     * </p>
+     */
+    public void fireChangeEventsOnFields() {
+        userNameEditor.fireChangeEvent();
+        passwordEditor.fireChangeEvent();
+        profileEditor.fireChangeEvent();
+    }
+
 }
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/AbstractValidatedWidgetWithLabel.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/AbstractValidatedWidgetWithLabel.java
index b22aac0..9b09ee3 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/AbstractValidatedWidgetWithLabel.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/AbstractValidatedWidgetWithLabel.java
@@ -12,11 +12,14 @@
 import com.google.gwt.event.dom.client.KeyDownHandler;
 import com.google.gwt.event.dom.client.KeyPressHandler;
 import com.google.gwt.event.dom.client.KeyUpHandler;
+import com.google.gwt.event.logical.shared.HasValueChangeHandlers;
+import com.google.gwt.event.logical.shared.ValueChangeEvent;
 import com.google.gwt.event.shared.HandlerRegistration;
 import com.google.gwt.resources.client.CssResource;
 import com.google.gwt.uibinder.client.UiBinder;
 import com.google.gwt.uibinder.client.UiField;
 import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.TakesValue;
 import com.google.gwt.user.client.ui.Focusable;
 import com.google.gwt.user.client.ui.HTMLPanel;
 import com.google.gwt.user.client.ui.SimplePanel;
@@ -302,4 +305,18 @@
     public void setKeepTitleOnSetEnabled(boolean keepTitleOnSetEnabled) {
         this.keepTitleOnSetEnabled = keepTitleOnSetEnabled;
     }
+
+    /**
+     * Force fire a change event on this field. This will trigger editor and 
model
+     * population from the field without a user edit and blur.
+     */
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    public void fireChangeEvent() {
+        W w = getContentWidget();
+        if (w instanceof TakesValue && w instanceof HasValueChangeHandlers) {
+            TakesValue t = (TakesValue) w;
+            HasValueChangeHandlers h = (HasValueChangeHandlers) w;
+            ValueChangeEvent.fire(h, t.getValue());
+        }
+    }
 }


-- 
To view, visit http://gerrit.ovirt.org/38017
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0364ac5c4524f5260480bca38642a6998d0c9147
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Greg Sheremeta <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to