/**
  * @param bool $performValidation
  *
  * @return bool
  */
 public function sendEmail($performValidation = true)
 {
     if ($performValidation and !$this->validate()) {
         return false;
     }
     $this->user->generateConfirmationToken();
     $this->user->save(false);
     return Yii::$app->mailer->compose(Yii::$app->yee->emailTemplates['password-reset'], ['user' => $this->user])->setFrom(Yii::$app->yee->emailSender)->setTo($this->email)->setSubject(Yii::t('yee/auth', 'Password reset for') . ' ' . Yii::$app->name)->send();
 }
 /**
  * @param bool $performValidation
  *
  * @return bool
  */
 public function updatePassword($performValidation = true)
 {
     if ($performValidation and !$this->validate()) {
         return false;
     }
     $this->user->password = $this->password;
     $this->user->removeConfirmationToken();
     return $this->user->save();
 }
 /**
  * @return mixed|string|\yii\web\Response
  */
 public function actionCreate()
 {
     $model = new User(['scenario' => 'newUser']);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['update', 'id' => $model->id]);
     }
     return $this->renderIsAjax('create', compact('model'));
 }
 protected function createUser($attributes)
 {
     $auth = ['source' => (string) $attributes['source'], 'source_id' => (string) $attributes['source_id']];
     unset($attributes['source']);
     unset($attributes['source_id']);
     $attributes['repeat_password'] = isset($attributes['password']) ? $attributes['password'] : NULL;
     $user = new User($attributes);
     $user->setScenario(User::SCENARIO_NEW_USER);
     $user->generateAuthKey();
     //$user->generatePasswordResetToken();
     $transaction = $user->getDb()->beginTransaction();
     if ($user->save()) {
         $auth = new Auth(['user_id' => $user->id, 'source' => $auth['source'], 'source_id' => $auth['source_id']]);
         if ($auth->save()) {
             $transaction->commit();
             Yii::$app->user->login($user);
         } else {
             Yii::$app->session->setFlash('error', 'Error 901: ' . Yii::t('yee/auth', "Authentication error occurred."));
             return Yii::$app->response->redirect(Url::to(['/auth/default/login']));
         }
     } else {
         $errors = $user->getErrors();
         $fields = ['username', 'email', 'password'];
         foreach ($fields as $field) {
             if (isset($errors[$field])) {
                 Yii::$app->session->setFlash('error', $user->getFirstError($field));
                 return Yii::$app->response->redirect(Url::to(['/auth/default/set-' . $field]));
             }
         }
         Yii::$app->session->setFlash('error', 'Error 902: ' . Yii::t('yee/auth', "Authentication error occurred."));
         return Yii::$app->response->redirect(Url::to(['/auth/default/login']));
     }
     Yii::$app->session->remove(AuthModule::PARAMS_SESSION_ID);
     return Yii::$app->response->redirect(Url::to(['/']));
 }