|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace yiicod\auth\controllers; |
|
4
|
|
|
|
|
5
|
|
|
use yii\helpers\ArrayHelper; |
|
6
|
|
|
use yii\web\Controller; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* WebUser controller |
|
10
|
|
|
* |
|
11
|
|
|
* @author Orlov Alexey <[email protected]> |
|
12
|
|
|
*/ |
|
13
|
|
|
class WebUserController extends Controller |
|
14
|
|
|
{ |
|
15
|
|
|
public $defaultAction = 'login'; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @inheritdoc |
|
19
|
|
|
*/ |
|
20
|
|
|
public function behaviors() |
|
21
|
|
|
{ |
|
22
|
|
|
return [ |
|
23
|
|
|
'access' => [ |
|
24
|
|
|
'class' => \yii\filters\AccessControl::className(), |
|
25
|
|
|
'rules' => [ |
|
26
|
|
|
[ |
|
27
|
|
|
'allow' => true, |
|
28
|
|
|
'actions' => ['login', 'logout', 'request-password-reset', 'signup', 'reset-password'], |
|
29
|
|
|
], |
|
30
|
|
|
], |
|
31
|
|
|
], |
|
32
|
|
|
'authUserBehavior' => [ |
|
33
|
|
|
'class' => \yiicod\auth\controllers\behaviors\AuthUserBehavior::className(), |
|
34
|
|
|
], |
|
35
|
|
|
]; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Declares class-based actions. |
|
40
|
|
|
* For change functional use AuthUserBehavior, This is component |
|
41
|
|
|
* declaret in to config.php, you can change him. |
|
42
|
|
|
* Auth event: |
|
43
|
|
|
* |
|
44
|
|
|
* - beforeLogin(ActionEvent) |
|
45
|
|
|
* - afterLogin(ActionEvent) |
|
46
|
|
|
* - errorLogin(ActionEvent) |
|
47
|
|
|
* |
|
48
|
|
|
* - beforeSignup(ActionEvent) |
|
49
|
|
|
* - afterSignup(ActionEvent) |
|
50
|
|
|
* - errorSignup(ActionEvent) |
|
51
|
|
|
* |
|
52
|
|
|
* - beforeCheckRecoveryKey(ActionEvent) |
|
53
|
|
|
* - afterCheckRecoveryKey(ActionEvent) |
|
54
|
|
|
* - errorCheckRecoveryKey(ActionEvent) |
|
55
|
|
|
* |
|
56
|
|
|
* - beforeForgot(ActionEvent) |
|
57
|
|
|
* - afterForgot(ActionEvent) |
|
58
|
|
|
* - errorForgot(ActionEvent) |
|
59
|
|
|
* |
|
60
|
|
|
* - beforeLogout(ActionEvent) |
|
61
|
|
|
* - afterLogout(ActionEvent) |
|
62
|
|
|
* |
|
63
|
|
|
* Also if you use extensions evenement, use this events, |
|
64
|
|
|
* Insert into listeners.php: |
|
65
|
|
|
* |
|
66
|
|
|
* ... |
|
67
|
|
|
* yiicod.auth.controllers.WebUserBase.[All event name before] |
|
68
|
|
|
* ... |
|
69
|
|
|
*/ |
|
70
|
|
|
public function actions() |
|
71
|
|
|
{ |
|
72
|
|
|
return ArrayHelper::merge(parent::actions(), [ |
|
73
|
|
|
'login' => [ |
|
74
|
|
|
'class' => \yiicod\auth\actions\webUser\LoginAction::className(), |
|
75
|
|
|
], |
|
76
|
|
|
'request-password-reset' => [ |
|
77
|
|
|
'class' => \yiicod\auth\actions\webUser\RequestPasswordResetAction::className(), |
|
78
|
|
|
], |
|
79
|
|
|
'logout' => [ |
|
80
|
|
|
'class' => \yiicod\auth\actions\webUser\LogoutAction::className(), |
|
81
|
|
|
], |
|
82
|
|
|
'signup' => [ |
|
83
|
|
|
'class' => \yiicod\auth\actions\webUser\SignupAction::className(), |
|
84
|
|
|
], |
|
85
|
|
|
'reset-password' => [ |
|
86
|
|
|
'class' => \yiicod\auth\actions\webUser\ResetPasswordAction::className(), |
|
87
|
|
|
], |
|
88
|
|
|
] |
|
89
|
|
|
); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|