Example #1
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = AdminUsers::findByUsername($this->username);
     }
     return $this->_user;
 }
Example #2
0
 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'only' => ['login', 'logout', 'index', 'error'], 'rules' => [['allow' => true, 'actions' => ['login', 'error'], 'roles' => ['?']], ['allow' => true, 'actions' => ['index', 'logout', 'error'], 'matchCallback' => function ($rule, $action) {
         if ($action != 'logout') {
             $model = models\AdminUsers::findIdentity(Yii::$app->user->getId());
             if (!empty($model)) {
                 return true;
                 // Администратор
             }
         }
         return false;
     }]]]];
 }
Example #3
0
 public function behaviors()
 {
     return ['verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post']]], 'access' => ['class' => AccessControl::className(), 'only' => ['index', 'view', 'create', 'update', 'delete'], 'rules' => [['allow' => true, 'actions' => ['index', 'view', 'create', 'update', 'delete'], 'matchCallback' => function ($rule, $action) {
         //                                if ($action != 'logout') {
         $model = AdminUsers::findIdentity(Yii::$app->user->getId());
         if (!empty($model)) {
             return true;
             // Администратор
         }
         return false;
         //                                }
         //                                return false;
     }]]]];
 }