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

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

1 parent b2d03962
......@@ -34,7 +34,7 @@ class AppAsset extends AssetBundle
"/css/styles.css",
];
public $js = [
'/app.js',
//'/app.js',
// "js/vit-gallery.js",
// "js/jquery.countTo.js",
// "js/jquery.appear.min.js",
......
......@@ -61,6 +61,7 @@ $config = [
'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => true,
'loginUrl' => ['/auth/login'],
],
'errorHandler' => [
'errorAction' => 'site/error',
......
......@@ -22,15 +22,16 @@ class SiteController extends Controller
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout'],
'rules' => [
[
'actions' => ['logout'],
'actions' => ['index','logout'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
......@@ -69,72 +70,4 @@ class SiteController extends Controller
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 @@
namespace app\modules\admin;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
/**
* admin module definition class
*/
class Module extends \yii\base\Module
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
],
],
],
];
}
/**
* {@inheritdoc}
*/
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!