Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
TatuLund committed May 27, 2024
1 parent 0856424 commit c72991c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ public class VaadinCreateUI extends UI implements EventBusListener, HasI18N {
protected void init(VaadinRequest request) {
getPage().setTitle("Vaadin Create 23'");
if (!getAccessControl().isUserSignedIn()) {
showLoginView();
showLoginView(request);
} else {
target = getInitialTarget();
showAppLayout();
}
eventBus.registerEventBusListener(this);
}

private void showLoginView() {
setContent(new LoginView(getAccessControl(), e -> onLogin()));
private void showLoginView(VaadinRequest request) {
setContent(new LoginView(getAccessControl(), e -> onLogin(request)));
}

private void onLogin() {
private void onLogin(VaadinRequest request) {
target = getInitialTarget();
logger.info("Initial target '{}'", target);
Utils.sessionFixation();
Utils.sessionFixation(request);
getPage().reload();
showAppLayout();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.jsoup.nodes.Document.OutputSettings;
import org.jsoup.safety.Safelist;

import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServletRequest;
import com.vaadin.shared.communication.PushMode;
import com.vaadin.ui.UI;
Expand All @@ -20,10 +20,9 @@ public static String sanitize(String unsanitized) {
return text;
}

public static void sessionFixation() {
public static void sessionFixation(VaadinRequest vaadinRequest) {
UI.getCurrent().getPushConfiguration().setPushMode(PushMode.DISABLED);
VaadinServletRequest request = (VaadinServletRequest) VaadinService
.getCurrentRequest();
VaadinServletRequest request = (VaadinServletRequest) vaadinRequest;
request.getHttpServletRequest().changeSessionId();
UI.getCurrent().getPushConfiguration().setPushMode(PushMode.AUTOMATIC);
}
Expand Down

0 comments on commit c72991c

Please sign in to comment.