Skip to content

Instantly share code, notes, and snippets.

@angelxmoreno
Created September 2, 2014 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelxmoreno/ede46b9d726db627589b to your computer and use it in GitHub Desktop.
Save angelxmoreno/ede46b9d726db627589b to your computer and use it in GitHub Desktop.
<?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