public function actionIndex($username)
 {
     if (!Yii::$app->user->getIsGuest()) {
         $model = new GuestlkForm();
         if ($model->load(Yii::$app->request->post())) {
             if (isset($_POST['savechanges-button'])) {
                 $uid = Yii::$app->user->getId();
                 //$model->updateUser($uid);
                 $userData = $model->updateUser($uid);
                 if (!$userData['error']) {
                     $model->initParams($userData);
                     return $this->render('index', ['model' => $model]);
                 } else {
                     Yii::$app->session->setFlash('error', Yii::t('registration', $userData['error'] . '_err_msg'));
                     $model->userId = Yii::$app->user->getId();
                     return $this->render('index', ['model' => $model]);
                 }
             }
         }
         $userData = UserIdentity::getUserData($username);
         $model->initParams($userData);
         return $this->render('index', ['model' => $model]);
     } else {
         return $this->goHome();
     }
 }
 public function validateAttribute($model, $attribute)
 {
     $identity = UserIdentity::findByLogin($model->login);
     if (!$identity) {
         $this->addError($model, $attribute, Yii::t('user', 'You do not have access to this service. You may have incorrectly entered your username or password. If the reason is not that - talk to your teacher'));
     }
 }
 /**
  * Finds user by [[username]]
  *
  * @return UserIdentity|null
  */
 public function getUser()
 {
     $this->_user = UserIdentity::findByUsername($this->username);
     return $this->_user;
 }
 public function actionLogout()
 {
     UserIdentity::logout();
     return $this->goHome();
 }
 public static function login($login)
 {
     $identity = UserIdentity::findByLogin($login);
     return Yii::$app->user->login($identity);
 }