| 13532 |
anikendra |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
class SignMeUpBehavior extends ModelBehavior {
|
|
|
4 |
|
|
|
5 |
public $validate = array(
|
| 15767 |
anikendra |
6 |
/*
|
| 13532 |
anikendra |
7 |
'username' => array(
|
|
|
8 |
'pattern' => array(
|
|
|
9 |
// 'rule' => array('custom','/[a-zA-Z0-9\_\-]{4,30}$/i'),
|
|
|
10 |
'rule' => array('email',true),
|
|
|
11 |
'message'=> 'Usernames must be 4 characters or longer with no spaces.'
|
|
|
12 |
),
|
|
|
13 |
'usernameExists' => array(
|
|
|
14 |
'rule' => 'isUnique',
|
|
|
15 |
'message' => 'Sorry, this username already exists'
|
|
|
16 |
),
|
|
|
17 |
),
|
|
|
18 |
'email' => array(
|
|
|
19 |
'validEmail' => array(
|
|
|
20 |
'rule' => array('email', true),
|
|
|
21 |
'message' => 'Please supply a valid & active email address'
|
|
|
22 |
),
|
|
|
23 |
'emailExists' => array(
|
|
|
24 |
'rule' => 'isUnique',
|
|
|
25 |
'message' => 'Sorry, this email address is already in use'
|
|
|
26 |
),
|
|
|
27 |
),
|
| 15767 |
anikendra |
28 |
*/
|
| 13532 |
anikendra |
29 |
'password1' => array(
|
|
|
30 |
'minRequirements' => array(
|
|
|
31 |
'rule' => array('minLength', 6),
|
|
|
32 |
'message' => 'Passwords need to be at least 6 characters long'
|
|
|
33 |
),
|
|
|
34 |
'match' => array(
|
|
|
35 |
'rule' => array('confirmPassword', 'password1', 'password2'),
|
|
|
36 |
'message' => 'Passwords do not match'
|
|
|
37 |
),
|
|
|
38 |
),
|
|
|
39 |
);
|
|
|
40 |
|
|
|
41 |
public function beforeValidate(&$Model) {
|
|
|
42 |
$this->model = $Model;
|
|
|
43 |
$this->model->validate = array_merge($this->validate, $this->model->validate);
|
|
|
44 |
return true;
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
public function confirmPassword($field, $password1, $password2) {
|
|
|
48 |
if ($this->model->data[$this->model->alias]['password1'] == $this->model->data[$this->model->alias]['password2']) {
|
|
|
49 |
$this->model->data[$this->model->alias]['password'] = Security::hash($this->model->data[$this->model->alias]['password1'], null, true);
|
|
|
50 |
return true;
|
|
|
51 |
}
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
public function generateActivationCode($data) {
|
|
|
55 |
return Security::hash(serialize($data).microtime().rand(1,100), null, true);
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
?>
|