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> вы теперь с phpNT!!!'); } else { Yii::$app->session->setFlash('error', 'Ошибка активации.'); Yii::error('Ошибка при активации.'); } return $this->redirect(Url::to(['/main/login'])); }
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', 'Activation for user <b>' . Html::encode($user->username) . '</b>' . ' has been done; <br> Enjoy your time!'); } else { Yii::$app->session->setFlash('error', 'Couldn`t activate ' . Html::encode($user->username)); Yii::error('Error activation for ' . Html::encode($user->username)); } return $this->redirect(Url::to(['/main/login'])); }
/** * 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', Yii::t('app', 'Success! You can now log in.') . ' ' . Yii::t('app', 'Thank you') . ' ' . Html::encode($user->username) . ' ' . Yii::t('app', 'for joining us!')); } else { Yii::$app->session->setFlash('error', Html::encode($user->username) . Yii::t('app', 'your account could not be activated, please contact us!')); } return $this->redirect('login'); }
/** * 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(); }