b0f143c3
Yarik
first commit
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<?php
namespace frontend\models;
use common\models\User;
use yii\base\Model;
use Yii;
/**
* Signup form
*/
class SignupForm extends Model
{
public $username;
public $email;
public $password;
|
f0f915df
Administrator
add Vitaliy's wid...
|
16
17
18
19
|
public $firstname;
public $lastname;
public $verifyCode;
public $location;
|
998611ce
Administrator
add Vitaliy's wid...
|
20
|
public $type;
|
b0f143c3
Yarik
first commit
|
21
22
23
24
25
26
27
28
29
30
31
32
|
/**
* @inheritdoc
*/
public function rules()
{
return [
['username', 'filter', 'filter' => 'trim'],
['username', 'required'],
['username', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This username has already been taken.'],
['username', 'string', 'min' => 2, 'max' => 255],
|
f0f915df
Administrator
add Vitaliy's wid...
|
33
34
|
['location', 'string', 'min' => 2, 'max' => 255],
|
b0f143c3
Yarik
first commit
|
35
36
37
38
39
40
|
['email', 'filter', 'filter' => 'trim'],
['email', 'required'],
['email', 'email'],
['email', 'string', 'max' => 255],
['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.'],
|
f0f915df
Administrator
add Vitaliy's wid...
|
41
42
|
['verifyCode', 'captcha'],
|
998611ce
Administrator
add Vitaliy's wid...
|
43
44
|
['type', 'integer'],
|
b0f143c3
Yarik
first commit
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
['password', 'required'],
['password', 'string', 'min' => 6],
];
}
/**
* Signs user up.
*
* @return User|null the saved model or null if saving fails
*/
public function signup()
{
if ($this->validate()) {
$user = new User();
$user->username = $this->username;
$user->email = $this->email;
$user->setPassword($this->password);
$user->generateAuthKey();
if ($user->save()) {
return $user;
}
}
return null;
}
}
|