Hi ...
I have a database one of the tables is table Users so it contain admin that allowed to access all thing and user to access some thing , my question is how when i log in by admin i want to be able to allow all thing but if i log in by user must be allow some thing or enable just some thing
pls help ....
Loading
Suthish NairPosted Sep 13, 2013, 5:19 AM
Abhishek JainPosted Sep 11, 2013, 11:01 AM
- You have Users Table, Create a Role table. Suppose two roles are there Admin & normal User
- Now Create a UserRoleMapping table in which you can assign different roles to different users
- Now create a Table for each Screen you add in your application. This table will contain the name of each screen(Can contain other details according to the requirement).
- Create a Table for Necessary Actions that user can perform. Suppose each screen can have following defined functionalities: Add, Edit, Delete, View, Print etc.
- Create table ScreenActionMapping which will map which all functionalities are present for each screen
- Create Table Permissions, this table will contain the mapping of Role, ScrenActionMapping.
- So now when the user logs in you have user id of that user, make a database hit, get the role of the user, corresponding to that role get all the data in Permissions and save it in user session. Now When the user comes to a particular screen you can check if the user is allowed to perform particular action and based on that you can show and hide the buttons.
- Additinally with this approach you can also get that if the user is having permissions to view that screen or not.
Hope it helps...Regards
AJ