This is a three part series in understanding the basics of using CakePHP's Auth component. You will nee... read more
This is a three part series in understanding the basics of using CakePHP's Auth component. You will need to watch all three videos as they build on to each other by adding more functionality to the application.
so I changed the beforefilter of users controller to
if($this->action == 'add' || $this->action == 'edit') {
if(Configure::read('isLoggedIn') && $this->action == 'edit') {
$this->Auth->authenticate = $this->User;
}
}
I write the user vars etc in the beforefilter of app controller
additionally if the user is unable to resiger (a guest adding themselves as a user) I set the password fields to blank (user controller add if the save does not work)
if($this->validateErrors($this->User)) {
//die('we get here');
$this->data['User']['password'] = '';
$this->data['User']['password_confirmation'] = '';
}
the $this->Auth->authenicate = $this->User; prevents guests from being able to resgister since guests do not pass authenication
I think the vars to hold authenicated user should be added to Configure so that a guest or admin can add (regualr users can't sign up once logged in)
well done :)
3 Comments