Answer the question
In order to leave comments, you need to log in
How to use module view in yii2?
Hello. Faced such a problem.
The authorization functionality has been moved to a separate module, which is called from the controller as follows:
frontend/controllers/SiteController.php
public function actions()
{
return [
'login' => 'common\modules\user\controllers\actions\LoginAction',
'logout' => 'common\modules\user\controllers\actions\LogoutAction',
'error' => [
'class' => 'yii\web\ErrorAction',
],
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}
public function run()
{
if (!\Yii::$app->user->isGuest) {
return $this->controller->goHome();
}
$model = new LoginForm();
$request = \Yii::$app->request;
if ($model->load($request->post()) && $model->validate()) {
$user = $model->getUser();
if (!$model->rememberMe) {
$this->expire = $this->expireNotRemember;
}
if ($this->service->login($user, $this->expire, $request)) {
if (\Yii::$app->user->login($user, $this->expire)) {
return $this->controller->goHome();
}
}
}
$model->password = '';
return $this->controller->render('login', [
'model' => $model,
]);
}
The view file does not exist: ***\frontend\views\site\login.php
Answer the question
In order to leave comments, you need to log in
Here is an example, just with the view setting for Standalone Actions:
https://www.yiiframework.com/doc/guide/2.0/en/stru...
https://www.yiiframework.com/doc/api/2.0/ yii-web-v...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question