daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest May 16th, 2018 214 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top