App::uses('AuthComponent', 'Controller/Component'); class User extends AppModel { 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 ) ) ); public $belongsTo = array('Group'); public $actsAs = array('Acl' => array('type' => 'requester')); public function parentNode() { if (!$this->id && empty($this->data)) { return null; } if (isset($this->data['User']['group_id'])) { $groupId = $this->data['User']['group_id']; } else { $groupId = $this->field('group_id'); } if (!$groupId) { return null; } else { return array('Group' => array('id' => $groupId)); } } public function beforeSave($options = array()) { if (isset($this->data[$this->alias]['password'])) { $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']); } return true; } public function bindNode($user) { return array('model' => 'Group', 'foreign_key' => $user['User']['group_id']); } } App::uses('AuthComponent', 'Controller/Component'); class User extends AppModel { 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 ) ) ); public $belongsTo = array('Group'); public $actsAs = array('Acl' => array('type' => 'requester')); public function parentNode() { if (!$this->id && empty($this->data)) { return null; } if (isset($this->data['User']['group_id'])) { $groupId = $this->data['User']['group_id']; } else { $groupId = $this->field('group_id'); } if (!$groupId) { return null; } else { return array('Group' => array('id' => $groupId)); } } public function beforeSave($options = array()) { if (isset($this->data[$this->alias]['password'])) { $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']); } return true; } public function bindNode($user) { return array('model' => 'Group', 'foreign_key' => $user['User']['group_id']); } }
Please enter your username and password
(default) 0 query took ms
NrQueryErrorAffectedNum. rowsTook (ms)