Created
September 2, 2014 04:39
-
-
Save angelxmoreno/ede46b9d726db627589b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// in the User Model | |
App::uses('AppModel', 'Model'); | |
App::uses('SimplePasswordHasher', 'Controller/Component/Auth'); | |
class User extends AppModel { | |
public function beforeSave($options = array()) { | |
if (isset($this->data[$this->alias]['password'])) { | |
$passwordHasher = new SimplePasswordHasher(); | |
$this->data[$this->alias]['password'] = $passwordHasher->hash( | |
$this->data[$this->alias]['password'] | |
); | |
} | |
return true; | |
} | |
public function hashy($string){ | |
$passwordHasher = new SimplePasswordHasher(); | |
return $passwordHasher->hash($string); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment