Thursday, May 5, 2011

Allowing actions

One of the main goals of this Coursework is define the permissions of each of the users depending of their roles. We have three kind of roles:
Admin
Registered User
Non Registered User

So, in order to allow certain actions to this users we have to first change the controller of each of the pages. Comments, Posts and Users. To explain this in this entry we are going to put the post as an example, for the rest the way to do it is quite similar.

First of all I have to change the beforeFilter function to allow the actions we want for each of the user. For the post we are going to allow both the admin and the registered user to add, edit and for all the users the view. Just for the admin is going to be the action to delete post. After changing this in the beforefilter function we have to define the authorization inside each of the functions (which are actions in our application) the visibility. Finally to show the actions to the users we have to change each of the views of the post folder, index, add, edit, delete....

No comments:

Post a Comment