Skip to content

Commit

Permalink
Add beforeSave() method to encrypt the password.
Browse files Browse the repository at this point in the history
  • Loading branch information
stinkinkevin committed Nov 5, 2015
1 parent 84b0b22 commit 875c0a9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/Model/User.php
Expand Up @@ -53,5 +53,13 @@ public function matchPasswords($data) {
$this->invalidate('password_confirmation', 'Your passwords do not match');
return false;
}

public function beforeSave($options = Array()) {
// encrypt the password before savig user info
if (isset($this->data['User']['password'])){
$this->data['User']['password'] = AuthComponent::password($this->data['User']['password']);
}
return true;
}
}
?>

0 comments on commit 875c0a9

Please sign in to comment.