Home » Java » spring boot – {Java} Vaadin 14 – Limit user to 1 (one) active UI-Exceptionshub

spring boot – {Java} Vaadin 14 – Limit user to 1 (one) active UI-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I posted this question java-vaadin-14-detect-user-leave-closes-tab-f5-etc but I think I asked the wrong questions.
I want to limit each signed-in user, to just one (1) active browser tab, or UI for that matter.

Someone told me to use VaadinSession.getCurrent().getUIs(), but this list is incremented by 1 (or 2 if @Push is enabled) every time the user refreshes the page. This means I can’t check if this list contains more than one (or 2).

I’m lost on this! With native java applications and a built-in login system, I can EASILY limit each user to just one (1) session. It’s harder with a browser. Or maybe it isn’t?

How to&Answers:

You could maybe register a UI init listener which closes all other UIs in the same session whenever a new UI is initialized?

See:

On the other hand, I would also be curious to understand why you want to prevent users from opening multiple tabs.