Hi All,
In this blog we will discuss how to change the password in cakePhp by using Auth.
Firstly, in your model you have to define a function beforeSave which will hash your password to auth password, you can do this by writing the below code:
- public function beforeSave($options = array()) {
- if (isset($this->data[$this->alias]['password'])) {
- $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
- }
- return true;
- }
In your change Password function you have to write-
- public function changePassword() {
- if ($this->data) {
- if (!empty($this->data['User']['password']) && !empty($this->data['User']['repassword'])) {
No comments:
Post a Comment