From e0ba0a9277d50184b29605e14707a79ed8a6e9eb Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 12 Nov 2020 17:00:32 +0100 Subject: [PATCH] fix login error --- .../seb/sebserver/gui/content/LoginPage.java | 20 +++++++++---------- .../service/page/impl/PageServiceImpl.java | 2 -- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/LoginPage.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/LoginPage.java index 8c4134bd..77acbecc 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/LoginPage.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/LoginPage.java @@ -88,9 +88,6 @@ public class LoginPage implements TemplateComposer { final Text loginPassword = this.widgetFactory.passwordInput(loginGroup); loginPassword.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); - final SEBServerAuthorizationContext authorizationContext = this.authorizationContextHolder - .getAuthorizationContext(RWT.getUISession().getHttpSession()); - final Composite buttons = new Composite(loginGroup, SWT.NONE); buttons.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); buttons.setLayout(new GridLayout(2, false)); @@ -103,16 +100,14 @@ public class LoginPage implements TemplateComposer { loginButton.addListener(SWT.Selection, event -> login( pageContext, loginName.getText(), - loginPassword.getText(), - authorizationContext)); + loginPassword.getText())); loginName.addListener(SWT.KeyDown, event -> { if (event.character == '\n' || event.character == '\r') { if (StringUtils.isNotBlank(loginPassword.getText())) { login( pageContext, loginName.getText(), - loginPassword.getText(), - authorizationContext); + loginPassword.getText()); } else { loginPassword.setFocus(); } @@ -124,8 +119,7 @@ public class LoginPage implements TemplateComposer { login( pageContext, loginName.getText(), - loginPassword.getText(), - authorizationContext); + loginPassword.getText()); } else { loginName.setFocus(); } @@ -144,11 +138,13 @@ public class LoginPage implements TemplateComposer { private void login( final PageContext pageContext, final String loginName, - final CharSequence loginPassword, - final SEBServerAuthorizationContext authorizationContext) { + final CharSequence loginPassword) { try { + final SEBServerAuthorizationContext authorizationContext = this.authorizationContextHolder + .getAuthorizationContext(); + final boolean loggedIn = authorizationContext.login( loginName, loginPassword); @@ -172,6 +168,8 @@ public class LoginPage implements TemplateComposer { } else { loginError(pageContext, "sebserver.login.failed.message"); + // disable user authorization + this.authorizationContextHolder.getAuthorizationContext(); } } catch (final Exception e) { log.error("Unexpected error while trying to login with user: {}", loginName, e); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageServiceImpl.java index d3fa3e5e..0fcc9b0e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageServiceImpl.java @@ -374,8 +374,6 @@ public class PageServiceImpl implements PageService { if (!logoutSuccessful) { log.warn("Failed to logout. See log-files for more information"); - pageContext.forwardToMainPage(); - pageContext.publishInfo(new LocTextKey("sebserver.error.logout")); return false; }