Example #1
0
 /**
  * Finds user by username.
  *
  * @return User|null User instance
  */
 protected function getUser()
 {
     if ($this->_user === null) {
         $scope = $this->module->isBackend ? ['admin', 'active'] : 'active';
         $this->_user = User::findByUsername($this->username, $scope);
     }
     return $this->_user;
 }
 /**
  * User page.
  *
  * @param string $username Username
  */
 public function actionView($username)
 {
     if (($model = User::findByUsername($username, 'active')) !== null) {
         return $this->render('view', ['model' => $model]);
     } else {
         throw new HttpException(404);
     }
 }
Example #3
0
 /**
  * Finds user by username.
  *
  * @return User|null User instance
  */
 protected function getUser()
 {
     if ($this->_user === null) {
         $scope = $this->scenario === 'admin' ? ['admin', 'active'] : 'active';
         $this->_user = User::findByUsername($this->username, $scope);
     }
     return $this->_user;
 }
Example #4
0
 /**
  * Finds user by username.
  *
  * @return User|boolean User instance
  */
 protected function getUser()
 {
     if ($this->_user === false) {
         $user = User::findByUsername($this->username, 'active');
         if ($user !== null) {
             if ($this->module->isBackend) {
                 if (Yii::$app->authManager->checkAccess($user->id, 'accessBackend')) {
                     $this->_user = $user;
                 }
             } else {
                 $this->_user = $user;
             }
         }
     }
     return $this->_user;
 }