Fix failed login feedback
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 1 Dec 2015 09:52:26 +0000 (09:52 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 1 Dec 2015 09:52:26 +0000 (09:52 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@8658 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.cms/src/org/argeo/cms/util/LoginEntryPoint.java
org.argeo.cms/src/org/argeo/cms/widgets/auth/CmsLogin.java

index abe67040643bfc96184fbff65572d446671dee17..a05165f5bf18796b66f83e0e01f8c838f4e77a97 100644 (file)
@@ -13,11 +13,11 @@ import org.argeo.cms.CmsException;
 import org.argeo.cms.CmsImageManager;
 import org.argeo.cms.CmsView;
 import org.argeo.cms.auth.AuthConstants;
+import org.argeo.cms.auth.CurrentUser;
 import org.argeo.cms.auth.HttpRequestCallbackHandler;
 import org.argeo.cms.ui.UxContext;
 import org.argeo.cms.widgets.auth.CmsLogin;
 import org.argeo.cms.widgets.auth.CmsLoginShell;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
 import org.argeo.eclipse.ui.specific.UiContext;
 import org.eclipse.rap.rwt.RWT;
 import org.eclipse.rap.rwt.application.EntryPoint;
@@ -44,22 +44,25 @@ public class LoginEntryPoint implements EntryPoint, CmsView {
                        CmsLoginShell loginShell = createCmsLoginShell();
                        loginShell.open();
                        while (!loginShell.getShell().isDisposed()) {
-                               try {
-                                       if (!display.readAndDispatch())
-                                               display.sleep();
-                               } catch (Exception e1) {
-                                       try {
-                                               Thread.sleep(3000);
-                                       } catch (InterruptedException e2) {
-                                               // silent
-                                       }
-                                       ErrorFeedback.show("Login failed", e1);
-                                       return -1;
-                               }
+                               // try {
+                               if (!display.readAndDispatch())
+                                       display.sleep();
+                               // } catch (Exception e1) {
+                               // try {
+                               // Thread.sleep(3000);
+                               // } catch (InterruptedException e2) {
+                               // // silent
+                               // }
+                               // ErrorFeedback.show("Login failed", e1);
+                               // return -1;
+                               // }
                        }
                } catch (LoginException e) {
                        throw new ArgeoException("Cannot log in", e);
                }
+
+               if (CurrentUser.getUsername() == null)
+                       return -1;
                uxContext = new SimpleUxContext();
                return postLogin();
        }
index 1051bd7239e0564f408711809c2b40f0ab4603c1..578386321dd197a8b76cecfdb7dd215b6608c235 100644 (file)
@@ -30,6 +30,7 @@ import org.argeo.cms.auth.CurrentUser;
 import org.argeo.cms.auth.HttpRequestCallback;
 import org.argeo.cms.i18n.LocaleUtils;
 import org.argeo.cms.util.CmsUtils;
+import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
 import org.argeo.util.LocaleChoice;
 import org.eclipse.rap.rwt.RWT;
 import org.eclipse.swt.SWT;
@@ -266,6 +267,12 @@ public class CmsLogin implements CmsStyles, CallbackHandler {
                        loginContext.login();
                } catch (FailedLoginException e) {
                        log.warn(e.getMessage());
+                       try {
+                               Thread.sleep(3000);
+                       } catch (InterruptedException e2) {
+                               // silent
+                       }
+                       ErrorFeedback.show("Login failed", e);
                        return false;
                } catch (LoginException e) {
                        log.error("Cannot login", e);