Guest User

Untitled

a guest
May 16th, 2018
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. <?php
  2.  
  3. // app/Model/User.php
  4. App::uses('AuthComponent', 'Controller/Component');
  5.  
  6. class User extends AppModel {
  7.  
  8.     public $name = 'User';
  9.     public $validate = array('username' => array('required' => array('rule' => array('notEmpty'), 'message' => 'A username is required')), 'password' => array('required' => array('rule' => array('notEmpty'), 'message' => 'A password is required')), 'role' => array('valid' => array('rule' => array('inList', array('admin', 'author')), 'message' => 'Please enter a valid role', 'allowEmpty' => false)));
  10.  
  11.     public function beforeSave() {
  12.         if (isset($this->data[$this->alias]['password'])) {
  13.             $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
  14.         }
  15.         return true;
  16.     }
  17.  
  18. }
Add Comment
Please, Sign In to add comment