Jmix sample login restriction project

The sample login restriction project as available in cuba is upgraded to jmix? I want to implement concurrent user login my jmix project.

Please advice?

You can use Authentication Events to implement your login restrictions.

Thanks @krivopustov for reply.

My requirement is that if user enter same login details then he will be shown a dialog to abort existing session.

I am using onPreAuthenticationCheckEvent for raising the exception - It is working.
Then i am aborting session by sessionRegistry. - not working

My code is

for (SessionInformation information : sessionRegistry.getAllSessions(userDetails, true)) {
if (!information.isExpired()) information.expireNow();
sessionRegistry.removeSessionInformation(information.getSessionId());
}

Second login is successful now but first user if refresh browser, he can also access app. Please advice.

I also need this capability; a user should be able to have only one session active at a time as we charge for access per-user.

@krivopustov
But are those logoutEvents guaranteed? What if a user just closes the browser?

note that I answered also in @modemmisuser other topic

You can use the standard HttpSessionListener to catch when HTTP session is destroyed.
See this thread.

1 Like