|
@@ -15,6 +15,8 @@ use app\models\Eventlog;
|
|
|
use app\models\Publishing;
|
|
use app\models\Publishing;
|
|
|
use yii\data\ActiveDataProvider;
|
|
use yii\data\ActiveDataProvider;
|
|
|
use yii\web\NotFoundHttpException;
|
|
use yii\web\NotFoundHttpException;
|
|
|
|
|
+use yii\web\Response;
|
|
|
|
|
+use yii\widgets\ActiveForm;
|
|
|
|
|
|
|
|
class SiteController extends Controller
|
|
class SiteController extends Controller
|
|
|
{
|
|
{
|
|
@@ -65,17 +67,24 @@ class SiteController extends Controller
|
|
|
'dataProvider' => $dataProvider,
|
|
'dataProvider' => $dataProvider,
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
public function actionLogin()
|
|
public function actionLogin()
|
|
|
{
|
|
{
|
|
|
if (!\Yii::$app->user->isGuest) {
|
|
if (!\Yii::$app->user->isGuest) {
|
|
|
return $this->goHome();
|
|
return $this->goHome();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$model = Yii::createObject(LoginForm::className());
|
|
$model = Yii::createObject(LoginForm::className());
|
|
|
|
|
+
|
|
|
|
|
+ if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
|
|
|
|
|
+ Yii::$app->response->format = Response::FORMAT_JSON;
|
|
|
|
|
+ return ActiveForm::validate($model);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
|
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
|
|
return $this->redirect(['/cabinet']);
|
|
return $this->redirect(['/cabinet']);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
return $this->render('login', [
|
|
return $this->render('login', [
|
|
|
'model' => $model,
|
|
'model' => $model,
|
|
|
]);
|
|
]);
|