Enabling session expired notification prevents seamless logout button
See original GitHub issueEnabling the session-expired notification via CustomizedSystemMessages.setSessionExpiredNotificationEnabled(true)
prevents me from having a seamless logout button since the “Session Expired” message flashes briefly when logging out.
The logout button is implemented as usual:
Button button = new Button("Logout",
e -> {
UI.getCurrent().getPage().setLocation("/");
VaadinSession.getCurrent().close();
VaadinSession.getCurrent().getSession().invalidate();
} );
Expected behavior
Pressing the button should reload the page without showing the “session expired” notification.
Actual behavior
Pressing the button will briefly show a red “session-expired” notification then reloads the page.
Workarounds
- Using
UI.getCurrent().getPage().open("/", "_self");
instead ofsetLocation()
as suggested at https://github.com/vaadin/framework/issues/4255 doesn’t help - the “session expired” notification still flashes. - Disable the session expired notification.
Versions:
- Vaadin / Flow version: 14.4.4 / 2.4.3
- Java version: 11
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Notifications request extends UI session, which prevents ...
Notifications request extends UI session, which prevents Session Timeout in LEX. ... "Disable session timeout warning popup" is unchecked.
Read more >Solving offline logout problem - Medium
have ability to properly logout the user when the device is online in order to stop push notifications to be delivered to the...
Read more >Possible way to make the page session expired in ASP MVC 3 ...
I have this security issue whereby I want to prevent user from relogin back with pressing back button after successfully log out from...
Read more >Application Session Management - Auth0
The session will last until a set expiration time or the user logs out, or the SSO session cookie is deleted from the...
Read more >Preventing Session Timeouts in C# ASP .NET Web Applications
To resolve this, the client may specify to increase the session timeout to several hours. Certainly, the operator would finish a call within...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is a mixture of various issues so I would like to have here a resume of the problem:
CustomizedSystemMessages
SessionCloseLogoutIT
which is initially broken and this fact allows it to pass in the branches where it’s enabled (see #10389: it enables the test in themaster
).Details are here:
LogoutView
from #9705 doesn’t use any system messages which means that the client side usesWidgetUtil.redirect(url)
logic on session expired.CustomizedSystemMessages
which enables another branch of the client side logic : it shows an error message instead of redirect .That’s why the behavior in the #9705 is different and randomly fails.
The
MessageHandler
(on the client side ,flow-client
) checks first whether there is session expired message and then it flushes all the command viaReactive.flush()
.As a result : there is no any reasons to execute “session expired” logic before other commands but in fact it’s better to execute session expired after since there can be commands which should “cancel” (or hide the effect of) session expired execution.
There is a
SessionCloseLogoutIT
which failed after changes in #10390 (that was the reason why the fix has been reverted). If fails because of totally different reasons. The test as initially broken because of https://github.com/vaadin/flow/issues/8177. The latter ticket is exactly about this usecase: Long Polling Push + redirect.SessionCloseLogoutView
has noCustomizedSystemMessages
which means thatWidgetUtil.redirect(url)
branch is used. And this execution is cancelled because of the #8177 bug. Then JS execution is handled properly. SoSessionCloseLogoutIT
works because it’s buggy. When #10390 is applied thewindow.location.href=
is cancelled instead ofWidgetUtil.redirect(url)
and this is exactly the #8177. SoSessionCloseLogoutIT
should not usewindow.location.href=
but it should usesetLocation
instead (which terminates the UI). This is fixed here : https://github.com/vaadin/flow/pull/10389Reopened, since the fix has been reverted due to regression.