When user clicks on sign out button, we call logOut() in UI class:
// Setting our own session attribute to null first
VaadinSession.getCurrent().setAttribute(MainView.CURRENT_USER, null);
UI.getCurrent().navigate(LoginView.class);
VaadinSession.getCurrent().close();
This will redirect user to the login page, but when they try to type in the login form (textfield), the UI refreshes again. If we remove VaadinSession.getCurrent().close(); the UI doesn’t refresh, but the session won’t properly close.
How can we properly close the session without the UI refreshing again?
Tatu Lund:
I would recommend to do it differently. Do something like below on logout, which will invalidate the session properly and reload with default route.