/**
  * @return string|\yii\web\Response
  */
 public function actionConfirmEmail()
 {
     if (Yii::$app->user->isGuest) {
         throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
     }
     $user = User::getCurrentUser();
     if ($user->email_confirmed == 1) {
         return $this->renderIsAjax('confirmEmailSuccess', compact('user'));
     }
     $model = new ConfirmEmailForm(['email' => $user->email, 'user' => $user]);
     if (Yii::$app->request->isAjax and $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post()) and $model->validate()) {
         if ($this->triggerModuleEvent(AuthEvent::BEFORE_EMAIL_CONFIRMATION_REQUEST, ['model' => $model])) {
             if ($model->sendEmail(false)) {
                 if ($this->triggerModuleEvent(AuthEvent::AFTER_EMAIL_CONFIRMATION_REQUEST, ['model' => $model])) {
                     return $this->refresh();
                 }
             } else {
                 Yii::$app->session->setFlash('error', Yii::t('yee/auth', "Unable to send message for email provided"));
             }
         }
     }
     return $this->renderIsAjax('confirm-email', compact('model'));
 }