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 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 Submit is clicked. This patch does just that. Now when Submit is clicked on the login form, "change" is fired on the username and password fields, which causes the 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 2 files changed, 34 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/34/37334/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 0eb417b..646aec0 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..eff9120 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 @@ -16,10 +16,13 @@ import org.ovirt.engine.ui.frontend.utils.FrontendUrlUtils; import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Document; +import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.editor.client.Editor.Ignore; import com.google.gwt.editor.client.Editor.Path; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; +import com.google.gwt.event.dom.client.DomEvent; import com.google.gwt.event.dom.client.HasKeyPressHandlers; import com.google.gwt.event.shared.EventBus; import com.google.gwt.i18n.client.LocaleInfo; @@ -197,4 +200,25 @@ return loginForm; } + /** + * <p> + * Force fire change events on the username and password fields. + * </p> + * <p> + * Our 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 Submit is clicked. + * </p> + */ + public void fireChangeEventsOnFields() { + NativeEvent event = Document.get().createChangeEvent(); + DomEvent.fireNativeEvent(event, userNameEditor.asValueBox()); + event = Document.get().createChangeEvent(); + DomEvent.fireNativeEvent(event, passwordEditor.asValueBox()); + } + } -- To view, visit http://gerrit.ovirt.org/37334 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0364ac5c4524f5260480bca38642a6998d0c9147 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Greg Sheremeta <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
