Commit 3bb0314f by Скуратович Александр

проверка авторизации

1 parent b2d03962
...@@ -34,7 +34,7 @@ class AppAsset extends AssetBundle ...@@ -34,7 +34,7 @@ class AppAsset extends AssetBundle
"/css/styles.css", "/css/styles.css",
]; ];
public $js = [ public $js = [
'/app.js', //'/app.js',
// "js/vit-gallery.js", // "js/vit-gallery.js",
// "js/jquery.countTo.js", // "js/jquery.countTo.js",
// "js/jquery.appear.min.js", // "js/jquery.appear.min.js",
......
...@@ -61,6 +61,7 @@ $config = [ ...@@ -61,6 +61,7 @@ $config = [
'user' => [ 'user' => [
'identityClass' => 'app\models\User', 'identityClass' => 'app\models\User',
'enableAutoLogin' => true, 'enableAutoLogin' => true,
'loginUrl' => ['/auth/login'],
], ],
'errorHandler' => [ 'errorHandler' => [
'errorAction' => 'site/error', 'errorAction' => 'site/error',
......
...@@ -22,15 +22,16 @@ class SiteController extends Controller ...@@ -22,15 +22,16 @@ class SiteController extends Controller
return [ return [
'access' => [ 'access' => [
'class' => AccessControl::className(), 'class' => AccessControl::className(),
'only' => ['logout'],
'rules' => [ 'rules' => [
[ [
'actions' => ['logout'], 'actions' => ['index','logout'],
'allow' => true, 'allow' => true,
'roles' => ['@'], 'roles' => ['@'],
], ],
], ],
], ],
'verbs' => [ 'verbs' => [
'class' => VerbFilter::className(), 'class' => VerbFilter::className(),
'actions' => [ 'actions' => [
...@@ -69,72 +70,4 @@ class SiteController extends Controller ...@@ -69,72 +70,4 @@ class SiteController extends Controller
return $this->render('index'); return $this->render('index');
} }
/**
* Login action.
*
* @return Response|string
*/
public function actionLogin()
{
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
}
$model->password = '';
return $this->render('login', [
'model' => $model,
]);
}
/**
* Logout action.
*
* @return Response
*/
public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}
/**
* Displays contact page.
*
* @return Response|string
*/
public function actionContact()
{
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('contactFormSubmitted');
return $this->refresh();
}
return $this->render('contact', [
'model' => $model,
]);
}
/**
* Displays about page.
*
* @return string
*/
public function actionAbout()
{
return $this->render('about');
}
public function actionError() {
$exception = Yii::$app->errorHandler->exception;
if ($exception !== null) {
return $this->render('error', ['exception' => $exception]);
}
}
} }
...@@ -2,11 +2,33 @@ ...@@ -2,11 +2,33 @@
namespace app\modules\admin; namespace app\modules\admin;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
/** /**
* admin module definition class * admin module definition class
*/ */
class Module extends \yii\base\Module class Module extends \yii\base\Module
{ {
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
],
],
],
];
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!