View Full Version : Disable / hide part of the UI according to users roles

17 Jan 2011, 11:03 PM
Dear all,

For a project I need to have part of the UI (ie admin section) not shown for non admin user. I also need to have readable only grid fields using a non privileged account while they must be editable using an admin account.

I came up with the idea of getting the user's object from an ajax request send right after ExtJS is ready. I then use it in the code like this :

if(Application.user.role == 'admin') {
//set buttons state, column model to editable, and so on
} else if (Application.user.role == 'moderator') {
} else {

While I think this is a viable solution I'd be really glad to know if there are better solution then this !

Edit : seems the way I'm doing was recommended back in 2009 by Condor (http://www.sencha.com/forum/showthread.php?76603-Users-access-to-some-part-of-the-app). Did anything change from then ?


18 Jan 2011, 12:19 AM
It's what my application is still doing.

ps. I did consider including the user object as a <script> tag instead of doing a separate XHR request. Saves you some extra coding (but your server needs to return javascript instead of JSON).

18 Jan 2011, 2:57 AM
It's what my application is still doing.

Fine, I'll stick with it then. Thanks alot !