/** * Valida la información de cambio de password. * Registra un codigo de cambio de password */ public function actionForgetPassword() { //* $this->layout = "tplLogin"; $message = ''; $model = new ForgetPasswordForm(); try { if (isset($_POST['ForgetPasswordForm'])) { $model->attributes = $_POST['ForgetPasswordForm']; if ($model->validate()) { self::serverValidationForgetPasswordForm($model); $email = strtolower(trim($model->email)); $changePasswordCode = UsersDao::getInstance()->updateChangePasswordCodeforValidUserActive($email); $ulrChangePassword = Constants::URL_CHANGE_PASSWORD_CODE . $changePasswordCode; $successMail = UtilsFunctions::sendMail(strtolower($email), Constants::SUBJECT_EMAIL_CHANGE_PASSWORD, Constants::HEAD_TEXT_CHANGE_PASSWORD, $ulrChangePassword, Constants::FOOTER_TEXT); $message = $successMail ? Constants::SUCCESS_MAIL_DELIVERY : Constants::NOT_SUCCESS_MAIL_DELIVERY; Yii::app()->user->setFlash('enter', $message); $this->refresh(); } } } catch (Exception $e) { Yii::app()->user->setFlash('enter', $e->getMessage()); $this->refresh(); } $this->render('forgetPassword', array('model' => $model, "errorSummary" => $message)); }
public function actionForgetPassword() { $model = new ForgetPasswordForm(); if (isset($_GET['done'])) { if (isset($_SESSION['forgetPasswordDone'])) { unset($_SESSION['forgetPasswordDone']); $this->render('forgetPasswordDone', array('model' => $model)); Yii::app()->end(); } else { $this->redirect(array('/site/forgetPassword')); } } if (!Yii::app()->user->isGuest) { $model->email = Yii::app()->user->name; } if (isset($_POST['ForgetPasswordForm'])) { $model->attributes = $_POST['ForgetPasswordForm']; if ($model->validate() && $model->sendMail()) { $_SESSION['forgetPasswordDone'] = true; $this->redirect(array('/site/forgetPassword', 'done' => 1)); } } $this->pageTitle = array('Forget Password'); $this->render('forgetPassword', array('model' => $model)); }