If someone looks inside the database or when he sign in my blog he will become a registered user and his role is going to be "reg".
The reason to use a role by default is to denny or allow accesebility to the controllers using that role. As for example in the post controller we can write this code :
When you sign in this role is associated by default and the registered user can't change it. The only user that can choose the role when he is adding a new user or editing a exisiting one is the admin.
The reason to use a role by default is to denny or allow accesebility to the controllers using that role. As for example in the post controller we can write this code :
That means that the admin is going to be able to add, edit and delete and the registered user only to add. But if you are a non-registered user you won't be able to add, edit or delete.function beforeFilter() {parent::beforeFilter();$this->Auth->deny('add','edit','delete');if ( $this->Auth->user('roles')=='admin')$this->Auth->allow('add','edit','delete');else if ($this->Auth->user('roles')=='reg')$this->Auth->allow('add');}
When you sign in this role is associated by default and the registered user can't change it. The only user that can choose the role when he is adding a new user or editing a exisiting one is the admin.
No comments:
Post a Comment