How, instead of displaying in the browser “Pay attention to any unsaved data, and click here to continue”, to automatically redirect the user to the login screen after the expiration of the HTTP session lifetime?
1 Like
Hello Alex!
You should override AppUI class and its method close() that is ivoked when session is expired or explicitly invoked.
MyAppAUI
public class MyAppUI extends AppUI {
@Autowired(required = false)
protected ServletContext servletContext;
@Override
public void close() {
super.close();
// Getting path to navigate
String contextPath = servletContext == null ? null : servletContext.getContextPath();
String logoutPath = Strings.isNullOrEmpty(contextPath) ? "/logout" : contextPath + "/logout";
// Navigate
AppUI.getCurrent().getPage().setLocation(logoutPath);
}
}
- Register it in application configuration class:
@Bean("my_AppUI")
@UIScope
@Primary
public AppUI appUi() {
return new MyAppUI();
}
- And exclude AppUI bean from context in
application.properties:
jmix.core.exclude-beans=appUI
2 Likes

it does not work, as before, instead of the authorization window, here is a message
How did you test session expiration? For instance, I’ve set in application.properties:
jmix.ui.http-session-expiration-timeout-sec=15
And it works.
jmix.ui.http-session-expiration-timeout-sec=10
thanks , everything worked !