Role-based views in extjs4 mvc

My application has different views for different roles like (administrator or standard user). I don't know how I can implement it with extjs4 MVC. The extjs4 documentation examples think the application has only one role, like standard user, so they create one app.js file that controls the application, but if the application has many roles, I don't know how to implement different views for different users. It's one thing that I have two app.js files in my application, and after I get the user role on the server, I load the appropriate app.js file to use the appropriate views, controllers, models, stores, etc.
It's true?

+3


source to share


1 answer


This is a pretty standard question that comes up so many times, and the answer is always the same:

  • Access control belongs to the server on which no one can manipulate it.
  • Just don't expose View / a model / a controller to a user who doesn't have access to

With that in mind, it doesn't matter if you have one app or ten.

And since Access Control has nothing to do with the interface, there is no implementation in ExtJS.

Update -> Hide UI Elements

A ready-to-go approach will use Ext.direct

. This provides the application with an API that can be modified based on the user access of the current user and then checked by the interface.

HowTo:



Create API based on user session and check Clientside like

if(Booking) {
   if (Booking.Create) {
       // has access
   }
}

      

or as one line

{
    xtype: 'button',
    hidden: !(Booking && Booking.Create)
}

      

This is a simple example of how easy it can be!

Update This link helped op

+2


source







All Articles