Actually there is validated beforeSave, and the password is hashed.
class User extends AppModel {
public $name = 'User';
public $hasOne = 'Tutor';
public $validate = array(
'username' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'A username is required'
)
),
'password' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'A password is required'
)
),
'role' => array(
'valid' => array(
'rule' => array('inList', array('student','tutor')),
'message' => 'Please enter a valid role',
'allowEmpty' => false
)
)
);
public function beforeSave() {
if (isset($this->data[$this->alias]['password'])) {
$this->data[$this->alias]['password'] =
AuthComponent::password($this->data[$this->alias]['password']);
}
return true;
}
}
On Mar 4, 6:01 pm, Tilen Majerle <tilen.maje...@gmail.com> wrote:
> $dataUser should be something like this
>
> $dataUser = array('User' => array('username' => $this->request-
>
> >data('LOGINTUTOR'), 'password' => $this->request-
> >data('PASSWORDTUTOR'), 'role' => 'tutor'));
>
> and make sure that model is not validated before save, maybe here is
> problem too :)
> --
> Lep pozdrav, Tilen Majerlehttp://majerle.eu
>
> 2012/3/4 Cédric Chabert <ced.chab...@gmail.com>
>
>
>
>
>
>
>
> > $dataUser = array('username' => $this->request-
> > >data('LOGINTUTOR'), 'password' => $this->request-
> > >data('PASSWORDTUTOR'), 'role' => 'tutor');
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment