I have the following scenario: My user has to be in many accessGroups but only one active at a specific moment. So I created a User_Group relation. The active one is the one saved on user. When the user changes the active Group I update the group field on user entity.
After doing this, how can I force refresh the session? For now, I just called the loginService.logout() and the user is forced to login again. Is there a way to avoid this?
If you want to logout user from web application you can use App object, as it is done by LogoutButton component:
App.getInstance().logout();
In this case, application will show confirmation dialog if there are unsaved changes in opened windows. If you want to force logout use Connection directly:
Unfortunately, you have to logout user from web client to replace the access group. You can implement automatic logout/login again logic in web application using Connection object, something like this:
Another approach that you might consider is the possibility to use user substitution to solbe this kind of problem. I used to use that in oder to achieve something similar…
You create multiple user accounts in different access groups with potentially different roles for a single user. Then you link those user accounts through user substitutions.
This way the user can actively switch between the different scenarios / hats that he wants to wear…
It actually worked great and did include only minimal programming…