Search code examples
authorizationuser-roles

Dynamic table creation regarding permission: design issue


Assume I've 2 user levels: user(u) and admin(a). I want to show both users a set of data, but the users is not permitted to see al data.

c1 | c2 | c3 | c4 |
-------------------
u/a| a  | u/a| a  |

In a MVC structure where do I have to determine which data needs to be shown? Do I have to check in the controller which data I need from my model? Or do I have to get all 4 columns and determine in my view whether the current viewer is a user or an admin? In case it is a user only column 1 and 3 has to be shown.


Solution

  • It seems to me that "what to show" is more along the lines of the view responsibilities.

    View requests the current users access level from model layer, and then , based on the acquired information, view requests either user or admin specific information and picks the appropriate templates for rendering the page.