/**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'only' => ['index', 'delete'], 'rules' => [['allow' => true, 'actions' => ['index', 'delete'], 'roles' => ['@'], 'matchCallback' => function () {
         //Llamada al método que comprueba si es un vendedor
         return \common\models\User::isUserAdmin(Yii::$app->user->identity->id);
     }]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['POST']]]];
 }
Пример #2
0
 public function loginAdmin()
 {
     if ($this->validate() && User::isUserAdmin($this->username)) {
         return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
     } else {
         return false;
     }
 }
Пример #3
0
 public function loginAdmin()
 {
     if ($this->validate() && User::isUserAdmin($this->username)) {
         return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
     } else {
         $this->addError('password', 'Incorrect username or password.');
         return false;
     }
 }
Пример #4
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'rules' => [['actions' => ['error'], 'allow' => true, 'matchCallback' => function ($rule, $action) {
         if (!User::isUserAdmin(Yii::$app->user->identity->username)) {
             return $this->redirect(['../']);
         } else {
             return true;
         }
     }], ['actions' => ['logout'], 'allow' => true, 'roles' => ['@']], ['actions' => ['login', 'index'], 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) {
         if (!User::isUserAdmin(Yii::$app->user->identity->username)) {
             return $this->redirect(['../']);
         } else {
             return true;
         }
     }]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['logout' => ['post']]]];
 }
Пример #5
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['POST']]], 'access' => ['class' => AccessControl::className(), 'rules' => [['allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) {
         return User::isUserAdmin(Yii::$app->user->identity->username);
     }]]]];
 }
 /**
  * Restrict access permissions to admin user and users with auth-item 'module-controller'
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'rules' => [['actions' => ['index', 'view', 'create', 'update', 'delete', 'recalculate'], 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) {
         return User::isUserAdmin(Yii::$app->user->identity->username);
     }]]]];
 }
Пример #7
0
echo Html::encode($this->title);
?>
</title>
    <?php 
$this->head();
?>
</head>
<body>
    <?php 
$this->beginBody();
?>
    <div class="wrap">
        <?php 
NavBar::begin(['brandLabel' => 'Origin of the Memes', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
$menuItems = [];
if (!Yii::$app->user->isGuest && User::isUserAdmin(Yii::$app->user->identity->username)) {
    $menuItems = [['label' => 'Vidmage', 'items' => [['label' => 'Vidmage List', 'url' => ['/vidmage/index']], ['label' => 'Vidmage New', 'url' => ['/vidmage/create']], ['label' => 'Category', 'url' => ['/category/index']], ['label' => 'Author', 'url' => ['/author/index']], ['label' => 'Tag', 'url' => ['/tag/index']]]], ['label' => 'Meme', 'url' => ['/meme/index']], ['label' => 'Platform', 'url' => ['/platform/index']]];
}
if (Yii::$app->user->isGuest) {
    $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else {
    $menuItems[] = ['label' => 'Logout (' . Yii::$app->user->identity->username . ')', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']];
}
$menuItems[] = ['label' => 'Frontend', 'url' => Yii::getAlias('@frontendUrl')];
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-left'], 'items' => $menuItems]);
NavBar::end();
?>

        <div class="container">
        <?php 
echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
Пример #8
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'rules' => [['actions' => ['login', 'error'], 'allow' => true], ['actions' => ['index', 'logout'], 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) {
         return User::isUserAdmin(Yii::$app->user->identity->username);
     }]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['logout' => ['post']]]];
 }