forked from hantsy/angularjs-cakephp-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.php
More file actions
46 lines (41 loc) · 1.25 KB
/
Copy pathUser.php
File metadata and controls
46 lines (41 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
App::uses('AppModel', 'Model');
/**
* User Model
*
*/
class User extends AppModel {
public function beforeSave($options = array()) {
if (isset($this->data[$this->alias]['password'])) {
$this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
}
if (!isset($this->data[$this->alias]['role'])) {
$this->data[$this->alias]['role'] = 'author';
}
// if (!isset($this->data[$this->alias]['is_active'])) {
// $this->data[$this->alias]['is_active'] = 1;
// }
return true;
}
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
)
)
);
}