コード例 #1
0
 /**
  * Make sure that user can activate his account if token is correct.
  */
 public function testActivationCorrect()
 {
     $model = new AccountActivation($this->user[1]['account_activation_token']);
     expect('account should be activated', $model->activateAccount())->true();
 }
コード例 #2
0
 /**
  * Activates the user account so he can log in into system.
  *
  * @param  string $token
  * @return \yii\web\Response
  *
  * @throws BadRequestHttpException
  */
 public function actionActivateAccount($token)
 {
     try {
         $user = new AccountActivation($token);
     } catch (InvalidParamException $e) {
         throw new BadRequestHttpException($e->getMessage());
     }
     if ($user->activateAccount()) {
         Yii::$app->session->setFlash('success', 'Success! You can now log in. 
             Thank you ' . Html::encode($user->username) . ' for joining us!');
     } else {
         Yii::$app->session->setFlash('error', '' . Html::encode($user->username) . ' your account could not be activated, 
             please contact us!');
     }
     return $this->redirect('login');
 }
コード例 #3
0
 public function actionActivateAccount($key)
 {
     try {
         $user = new AccountActivation($key);
     } catch (InvalidParamException $e) {
         throw new BadRequestHttpException($e->getMessage());
     }
     if ($user->activateAccount()) {
         Yii::$app->session->setFlash('success', 'Активация прошла успешно, <strong>' . Html::encode($user->username) . '</strong>. Добро пожаловать на сайт gapchich.ru');
     } else {
         Yii::$app->session->setFlash('error', 'Ошибка активации.');
         Yii::error('Ошибка при активации.');
     }
     return $this->redirect(Url::to(['/site/login']));
 }