_service = $service; } /** * @return mixed */ public function actionRequest() { $form = new PasswordResetRequestForm(); if ($form->load(Yii::$app->request->post()) && $form->validate()) { try { $this->_service->request($form); Yii::$app->session->setFlash('success', Yii::t('auth', 'Check your email for further instructions.')); return $this->goHome(); } catch (\DomainException $e) { Yii::$app->errorHandler->logException($e); Yii::$app->session->setFlash('error', $e->getMessage()); } } return $this->render('request', [ 'model' => $form, ]); } /** * @param $token * @return mixed * @throws BadRequestHttpException */ public function actionConfirm($token) { try { $this->_service->validateToken($token); } catch (\DomainException $e) { throw new BadRequestHttpException($e->getMessage()); } $form = new ResetPasswordForm(); if ($form->load(Yii::$app->request->post()) && $form->validate()) { try { $this->_service->reset($token, $form); Yii::$app->session->setFlash('success', Yii::t('auth', 'New password saved.')); } catch (\DomainException $e) { Yii::$app->errorHandler->logException($e); Yii::$app->session->setFlash('error', $e->getMessage()); } return $this->goHome(); } return $this->render('confirm', [ 'model' => $form, ]); } }