diff --git a/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/VaadinCreateUI.java b/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/VaadinCreateUI.java index 1d6b71a0..57134fa 100644 --- a/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/VaadinCreateUI.java +++ b/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/VaadinCreateUI.java @@ -64,13 +64,7 @@ public class VaadinCreateUI extends UI implements EventBusListener, HasI18N { protected void init(VaadinRequest request) { getPage().setTitle("Vaadin Create 23'"); if (!getAccessControl().isUserSignedIn()) { - setContent(new LoginView(getAccessControl(), e -> { - target = getInitialTarget(); - logger.info("Initial target '{}'", target); - Utils.sessionFixation(); - getPage().reload(); - showAppLayout(); - })); + showLoginView(); } else { target = getInitialTarget(); showAppLayout(); @@ -78,6 +72,18 @@ protected void init(VaadinRequest request) { eventBus.registerEventBusListener(this); } + private void showLoginView() { + setContent(new LoginView(getAccessControl(), e -> onLogin())); + } + + private void onLogin() { + target = getInitialTarget(); + logger.info("Initial target '{}'", target); + Utils.sessionFixation(); + getPage().reload(); + showAppLayout(); + } + private String getInitialTarget() { if (getPage().getUriFragment() == null) { return AboutView.VIEW_NAME; diff --git a/vaadincreate-ui/src/test/java/org/vaadin/tatu/vaadincreate/AbstractUITest.java b/vaadincreate-ui/src/test/java/org/vaadin/tatu/vaadincreate/AbstractUITest.java index bce81f8..7f445c9 100644 --- a/vaadincreate-ui/src/test/java/org/vaadin/tatu/vaadincreate/AbstractUITest.java +++ b/vaadincreate-ui/src/test/java/org/vaadin/tatu/vaadincreate/AbstractUITest.java @@ -1,14 +1,15 @@ package org.vaadin.tatu.vaadincreate; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import org.vaadin.tatu.vaadincreate.crud.BookGrid; import org.vaadin.tatu.vaadincreate.crud.FakeGrid; import org.vaadin.tatu.vaadincreate.i18n.DefaultI18NProvider; -import org.vaadin.tatu.vaadincreate.i18n.I18NProvider; import org.vaadin.tatu.vaadincreate.login.LanguageSelect; +import com.vaadin.server.VaadinSession; import com.vaadin.testbench.uiunittest.UIUnitTest; import com.vaadin.ui.Button; @@ -20,13 +21,15 @@ public abstract class AbstractUITest extends UIUnitTest { protected void login() { + var sessionId = VaadinSession.getCurrent().getSession().getId(); test($(TextField.class).id("login-username-field")).setValue("Admin"); test($(PasswordField.class).id("login-password-field")) .setValue("admin"); test($(LanguageSelect.class).first()) .clickItem(DefaultI18NProvider.LOCALE_EN); test($(Button.class).id("login-button")).click(); - + assertNotEquals(sessionId, + VaadinSession.getCurrent().getSession().getId()); } protected void logout() {