Register dynamic routes for session scopes

My Vaadin24 Spring Boot app should display a view after the login, that depends on the role of the logged-in user. The dynamic registration of a route in the spring security authSuccessHandler fails because no Vaadin session exists at this time and therefore the call to RouteConfiguration.forSessionScope().setRoute("", RoleXYZView.class);
fails with Null session is not supported for session route registry

When and where should such session scoped dynamic route registrations be made?

The good example from does not use Spring Security and therefore does not help.

Kind regrads

The usage of spring application event also doesn’t work due to the same reason: it’s called too early and no Vaadin sessions exists.

    public ApplicationListener<ApplicationEvent> successHandler() {
        return event -> {
            if (event instanceof InteractiveAuthenticationSuccessEvent authSuccessEvent) {

Why not doing it in the Vaadin Session Init Listener?

Perfect :+1:t2:

Rejoiced too soon, doesn’t work after all, but also this is the wrong Thread (it’s a flow issue) so I make a new post over there