|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* _ __ __ _____ _____ ___ ____ _____ |
|
5
|
|
|
* | | / // // ___//_ _// || __||_ _| |
|
6
|
|
|
* | |/ // /(__ ) / / / /| || | | | |
|
7
|
|
|
* |___//_//____/ /_/ /_/ |_||_| |_| |
|
8
|
|
|
* @link https://vistart.me/ |
|
9
|
|
|
* @copyright Copyright (c) 2016 - 2017 vistart |
|
10
|
|
|
* @license https://vistart.me/license/ |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace rhosocial\user\web\user\controllers; |
|
14
|
|
|
|
|
15
|
|
|
use rhosocial\user\forms\ChangePasswordForm; |
|
16
|
|
|
use Yii; |
|
17
|
|
|
use yii\filters\AccessControl; |
|
18
|
|
|
use yii\web\Controller; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @version 1.0 |
|
22
|
|
|
* @author vistart <[email protected]> |
|
23
|
|
|
*/ |
|
24
|
|
|
class SecurityController extends Controller |
|
25
|
|
|
{ |
|
26
|
|
|
const SESSION_KEY_CHANGE_PASSWORD_MESSAGE = 'session_key_change_password_message'; |
|
27
|
|
|
|
|
28
|
|
|
public $changePasswordSuccessMessage = 'Password Changed.'; |
|
29
|
|
|
|
|
30
|
|
|
public $changePasswordFailedMessage = 'Password Not Changed.'; |
|
31
|
|
|
|
|
32
|
|
|
public function behaviors() |
|
33
|
|
|
{ |
|
34
|
|
|
return [ |
|
35
|
|
|
'access' => [ |
|
36
|
|
|
'class' => AccessControl::class, |
|
37
|
|
|
'rules' => [ |
|
38
|
|
|
[ |
|
39
|
|
|
'actions' => ['index', 'change-password', 'login-log'], |
|
40
|
|
|
'allow' => allow, |
|
41
|
|
|
'roles' => ['@'], |
|
42
|
|
|
] |
|
43
|
|
|
], |
|
44
|
|
|
], |
|
45
|
|
|
]; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function actionIndex() |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->render('index'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function actionChangePassword() |
|
54
|
|
|
{ |
|
55
|
|
|
$model = new ChangePasswordForm(); |
|
56
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->changePassword()) { |
|
57
|
|
|
$model = new ChangePasswordForm(); |
|
58
|
|
|
Yii::$app->session->setFlash(self::SESSION_KEY_CHANGE_PASSWORD_MESSAGE, $this->changePasswordSuccessMessage); |
|
59
|
|
|
} else { |
|
60
|
|
|
$model = new ChangePasswordForm(); |
|
61
|
|
|
Yii::$app->session->setFlash(self::SESSION_KEY_CHANGE_PASSWORD_MESSAGE, $this->changePasswordFailedMessage); |
|
62
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
return $this->render('change-password', ['model' => $model]); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function actionLoginLog() |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->render('login-log'); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|