jmix
jmix copied to clipboard
Direct opening of the login view may lead to multiple user sessions
Environment
Jmix version: 2.7.0 Source: forum
Bug Description
If we directly open the login view and enter user credentials, this leads to multiple user sessions.
Steps To Reproduce
- Open the first browser tab
- Login to the app with
user1 - Open the second browser tab which is already has user session:
user1 - In the first tab: navigate the login view, e.g. by browser history
-
In the first tab: Login as
user2 - Switch to the second browser tab
Current Behavior
Multiple browser tabs have different user sessions
Expected Behavior
Possible solutions:
- Either redirect to the main view or previous view if there is an active user.
- Previously logged-in user is logged out
- Disable login view if there is an active user
I vote for Option no. 2 (Previously logged-in user is logged out)
As a work around, add the following to the LoginView:
@Autowired
private CurrentAuthentication currentAuthentication;
@Override
public void beforeEnter(BeforeEnterEvent event) {
if (!(currentAuthentication.getAuthentication() instanceof AnonymousAuthenticationToken)) {
event.rerouteTo("");
return;
}
super.beforeEnter(event);
}