/**
  * Attempts changing user's email address.
  *
  * @param int    $id
  * @param string $code
  *
  * @return string
  * @throws \yii\web\HttpException
  */
 public function actionConfirm($id, $code)
 {
     $user = $this->finder->findUserById($id);
     if ($user === null || $this->module->emailChangeStrategy == Module::STRATEGY_INSECURE) {
         throw new NotFoundHttpException();
     }
     $event = $this->getUserEvent($user);
     $this->trigger(self::EVENT_BEFORE_CONFIRM, $event);
     $user->attemptEmailChange($code);
     $this->trigger(self::EVENT_AFTER_CONFIRM, $event);
     return $this->redirect(['account']);
 }
 /**
  * Confirms user's account. If confirmation was successful logs the user and shows success message. Otherwise
  * shows error message.
  *
  * @param int    $id
  * @param string $code
  *
  * @return string
  * @throws \yii\web\HttpException
  */
 public function actionConfirm($id, $code)
 {
     $user = $this->finder->findUserById($id);
     if ($user === null || $this->module->enableConfirmation == false) {
         throw new NotFoundHttpException();
     }
     $event = $this->getUserEvent($user);
     $this->trigger(self::EVENT_BEFORE_CONFIRM, $event);
     $user->attemptConfirmation($code);
     $this->trigger(self::EVENT_AFTER_CONFIRM, $event);
     return $this->render('/message', ['title' => Yii::t('user', 'Account confirmation'), 'module' => $this->module]);
 }
Beispiel #3
0
 /**
  * Finds the User model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  *
  * @param int $id
  *
  * @return User the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     $user = $this->finder->findUserById($id);
     if ($user === null) {
         throw new NotFoundHttpException('The requested page does not exist');
     }
     return $user;
 }