I am building a portal that will use classic Phoenix templates and some sections where connectivity will be done via channels (still not sure… what that will use : LiveView, react, elm??).
Just for the sake of explanation, please see this random example:
Let’s say that we have the top navbar (in the top 2 rows), then we have a sidebar on the left and the central component part as the rest of the page. Let’s assume that this central part will be probably connected via channels. Left and top will be rendered via classic phoenix templates.
Now the question/dilemma.
I need authentication, which will be probably based on Phx.gen.auth, but the critical part is an authorization. I need a minimum of 4 different roles.
For instance, based on a specific role, the left sidebar could be different. Or the central part might be missing an element or two which are part of the central “rendered page”. So part of this central component. Based on the role, the top navbar could be different. And so on. You probably get the picture by now.
The majority of the material on the net shows a classic approach with “admin” and “user” roles, probably plug implementation for authorization then dealing with “who can see what” on the level of routes.ex file.
But how would you approach this in my case, where based on the role, you need to change/modify random component/template.
Next, would it be better to open totally different template files based on roles… or modify somehow one and only template that we would have for instance for this central part… and modify it “in-place” based on the role? What would be a more idiomatic approach?
I would really appreciate some feedback.
Thanks in advance.