To make the elements hidden / visible on the screen, I do inline checks in my template, something like:
<% if (user.isInRole('ADMIN', 'MNGR')) { %> <li <% page == "store" ? print('class="active"') :'' %>> </li> <% } %>
and added the following helper function to my user model to check permissions:
isInRole: function (rr) { var self = this; $.each(rr, function(i) { if (rr[i] === self.currentRole) { alert('pass'); } }); }
I assume this is safe enough, since the actual verification of the required permission happens again on the server side. Concealing some controls, I simply direct the user through the application and do not allow him to be confused with actions, since he does not have the necessary privileges.
With this approach, I never hide data that comes dynamically through REST services, only a static page element.
Akos K
source share