1: <?php
 2: 
 3: App::uses('AuthComponent', 'Controller/Component');
 4: 
 5: class User extends AppModel{        
 6: 
 7:     public $validate = array(
 8:         'name' => array(
 9:             'notEmpty' => array(
10:                 'rule' => 'notEmpty',
11:                 'required' => true,
12:             ),
13:         ),
14:         'email' => array(
15:             'notEmpty' => array(
16:                 'rule' => 'notEmpty',
17:                 'required' => true,
18:                 'last' => true,
19:             ),
20:             'email' => array(
21:                 'rule' => 'email',
22:                 'required' => true,
23:             ),
24:             'isUnique' => array(
25:                 'rule' => 'isUnique',
26:                 'required' => true,
27:             ),
28:         ),
29:     );
30: 
31:     public function beforeSave($options = array()) {
32:         if (!empty($this->data[$this->alias]['password'])) {
33:             $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
34:         }
35:         
36:         return true;
37:     }
38: 
39: }
40: 
41: ?>
42: