Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
[BZ 1150586] - On first login attempt, LDAP user remains on login scr…
Browse files Browse the repository at this point in the history
…een without any message when - Enable Login Without Roles=No and there is no mapping between JON roles and LDAP groups. - Displaying the generic error message for the first attemnt as well. Also disabling the login button, during the login procedure, because login using LDAP takes some time and we don't want users to click on the button invoking another checks.
  • Loading branch information
jkremser committed Oct 17, 2014
1 parent f3ecc79 commit adc7dab
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public class LoginView extends Canvas {

private Window window;
private FormPanel fakeForm;
private DynamicForm form;
private static DynamicForm form;
private DynamicForm inputForm;

private SubmitItem loginButton;
Expand Down Expand Up @@ -122,12 +122,12 @@ public class LoginView extends Canvas {
private static final String LOGIN_ERROR_DIV_ID = "loginError";
private static final String ERROR_FEEDBACK_DIV_ID = "errorFeedback";
private static final String HTML_ID = "htmlId";
private String errorMessage;
private static String errorMessage;
private static volatile boolean isLoginView = true;

private ProductInfo productInfo;

public void showLoginDialog(String message) {
public void showLoginDialog(final String message) {
if (!loginShowing) {
errorMessage = message;
if (!isLoginView()) {
Expand All @@ -137,11 +137,14 @@ public void showLoginDialog(String message) {
showLoginDialog(false);
} else {
form.setErrorsPreamble(message);
form.setFieldErrors("login", message, true);
setLoginError(message);
setLoginButtonDisabled(false);
}
}

public void showLoginDialog(boolean isLogout) {
setLoginButtonDisabled(false);
if (!loginShowing) {
if (isLogout) {
UserSessionManager.logout();
Expand Down Expand Up @@ -234,7 +237,9 @@ public void onSubmitValues(SubmitValuesEvent submitValuesEvent) {
injectLoginFunction(this);

if (errorMessage != null) {
form.setFieldErrors("login", MSG.view_login_noUser(), true);
form.setErrorsPreamble(errorMessage);
form.setFieldErrors("login", errorMessage, true);
setLoginError(errorMessage);
errorMessage = null; // hide it next time
}
}
Expand Down Expand Up @@ -565,8 +570,8 @@ private void loadValidators(DynamicForm form) {
}

private void login(final String username, final String password) {

loginButton.setDisabled(true);
setLoginError(null);
setLoginButtonDisabled(true);

try {
RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.POST, "/portal/j_security_check.do");
Expand Down Expand Up @@ -622,7 +627,7 @@ private void handleError(int statusCode) {
form.setFieldErrors("login", MSG.view_login_noBackend(), true);
setLoginError(MSG.view_login_noBackend());
}
loginButton.setDisabled(false);
setLoginButtonDisabled(false);
}

/**
Expand Down Expand Up @@ -666,6 +671,16 @@ private void setLoginError(String error) {
feedbackDiv.setClassName(error != null ? "showError" : "hideError");
}
}

private void setLoginButtonDisabled(boolean disabled) {
if (null != loginButton) {
loginButton.setDisabled(true);
}
Element button = DOM.getElementById(LOGINBUTTON_ID);
if (button != null) {
button.setClassName("btn btn-primary btn-lg" + (disabled ? " disabled" : ""));
}
}

// This is our JSNI method that will be called on form submit
private native void injectLoginFunction(LoginView view) /*-{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ public void onFailure(Throwable caught) {
// to any LDAP users, previously registered or not.
Log.debug("Failed to complete ldap processing for subject: "
+ caught.getMessage());
//TODO: pass message to login dialog.
new LoginView().showLoginDialog(true);
new LoginView().showLoginDialog(MSG.view_login_noUser());
return;
}

Expand Down

0 comments on commit adc7dab

Please sign in to comment.