Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting permission on certain part of an application

 
Dalia Sultana
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to enable/disable certain parts of an application depending on the user's role. Every dialog at start up checks for the role of the current user and enables or disables various parts. Somehow it doesn't seem that object oriented to me but can't think of a better way either. I was just wondering if there is a standard way to do this.

Thanks,

Dalia
 
Campbell Ritchie
Sheriff
Posts: 48454
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a call to the Strategy pattern.

Put all your users into a HashMap, with objects representing their access status; loading that object at log-in time will activate and deactivate the appropriate parts of the application.
 
Dalia Sultana
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure, I follow your suggestion. Perhaps, I was unclear as to what it is that I am trying to achieve. The application has many dialogs with buttons, tables and checkboxes. Depending on what user is currently accessing it certain buttons/checkboxes need to disappear or become disabled. This is currently done at initialization of the dialog. I was wondering if there is a way to extract this part of the code out in a different module somehow. These bits and pieces of code check to see what role the user has and then enables/disables the appropriate buttons/checkboxes. I am not sure if this is the best way to this. I was just wondering if there is a standard/well accepted way to do this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic