Advertisement
Guest User

Untitled

a guest
Jul 30th, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. <?php
  2.  
  3. App::uses('AppModel', 'Model');
  4. App::uses('BlowfishPasswordHasher', 'Controller/Component/Auth');
  5.  
  6. class User extends AppModel {
  7.  
  8. public function beforeSave($options = array())
  9. {
  10. parent::beforeSave($options = array());
  11. $this->data['User']['resetkey'] = Security::hash(mt_rand(),'md5',true);
  12. if (isset($this->data[$this->alias]['password'])) {
  13. $this->data[$this->alias]['password'] = Security::hash($this->data[$this->alias]['password'], 'blowfish', false);
  14. }
  15. return true;
  16. }
  17.  
  18. public $displayField = 'user';
  19. public $_schema = array
  20. (
  21. 'language' => array
  22. (
  23. 'length' => 3
  24. )
  25. );
  26.  
  27. public $validate = array(
  28. 'user' => array(
  29. 'required' => array
  30. (
  31. 'rule' => array('notEmpty'),
  32. 'message' => 'Ein Benutzername wird benötigt'
  33. ),
  34. 'unique' => array
  35. (
  36. 'rule' => array('isUnique'),
  37. 'message' => 'Benutzername bereits vergeben!'
  38. )
  39. ),
  40. 'password' => array
  41. (
  42. 'required' => array(
  43. 'rule' => array('notEmpty'),
  44. 'message' => 'Ein Passwort wird benötigt!'
  45. )
  46. ),
  47. 'role' => array
  48. (
  49. 'valid' => array
  50. (
  51. 'rule' => array('inList', array('admin', 'user')),
  52. 'message' => 'Bitte eine gültige Rolle eingeben',
  53. 'allowEmpty' => false
  54. )
  55. ),
  56. 'email' => array
  57. (
  58. 'rule' => array('email'),
  59. 'message' => 'Bitte geben Sie eine gültige E-Mail Adresse an',
  60. 'allowEmpty' => false
  61. )
  62. );
  63. }
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement