Dynamically adding new "Home" View for specific Users depending on his "Company"

Hey there :slight_smile:

Following more or less this guide here:

So far so … don’t know :slight_smile:
The new “Home” View shall be only for Users belonging to a certain company.

My Problem:
Users may belong to more than one company, which they can set within a UserSettings View. That selected company has a specific role within the business processes, and derived from that role (which is not a Spring Boot Security Role) the new Home View shall replace the Standard Home view. Not necessarily on the fly but at login.

Dynamical Routing is not the problem here but to get that role after login.
MainView uses the SideNav adding routes to the Menu. But in that moment after login I have yet no access to the company nor the company role, I get null if asking for that.

What would be best way to proceed? Kinda page refresh after login had happend? Kind of “delay” using e.g. ui.access? Or something totally different, as e.g. adding company role to the User, too, beside ADMIN, User, etc.? (Would probably be tad more work…)

Or does anyone has any other complete different ideas?
Using Flow 24.8.2, Spring Boot 3.5.2 and Java 21

Open for suggestions :wink:

Cheers
Mojo

My first suggestion would be to have a “dummy view” as home which checks when navigating “what org is my user” → redirect to the correct view or load that view inside the dummy view

1 Like

That beautiful short tells me that I too often think just too complicated :laughing:
Yes, nice idea though!

Since the content of the home view can be different depending on the role and dynamic routing seems not to be an option, I would suggest to simply setup the home view content on the fly:

  • You could setup the contents of the home view, when it is navigated to. At this point you should have the user role - if not, then nothing can be shown
  • Depending on the role, you can add certain components to the view to display the content needed.
  • So for instance, if the user has role A, you can add component X to your home view. If the user has role B, you can add component Y. And if the user has both roles, you can add both components.
1 Like

:laughing: Don’t know which of the answers mark as solution as the both mean the same :slight_smile:

Yes, I had that dynamical routing in mind when starting this, and yes, it is too much for such “simple” problem. Thanks both of you for cleaning up my mind! Still no idea why I haven’t thought of that by myself. Good to have this community :+1:

Thanks!
Mojo

Just as short info: works already in general.

All I can say now:
keepitsimplestupid