Tuesday, October 28, 2014

Re: After I change my User.name, can not log in..

Ok, I solved my problem. 
After the admin save user settings without password fields in the User model we have beforesave method, which returns a hash password, in this case the function create a new password from scratch and save it into the database. 

solution: 

UsersController :: admin_edit (): 

put a dummy data 

$this -> request -> data ['User']['dummy'] == true;

 
User model

public function beforeSave($options = array())
{
        if(!isset($this->data['User']['dummy'])) {
       $this->data['User']['password'] = AuthComponent::password(
         $this->data['User']['password']
       );
}
        return true;
    }


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: