示例#1
0
 public function actionForgotPassword()
 {
     $isSuccessfull = false;
     $model = new ForgotPasswordForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         //send forgot password retrieval email to the client
         $isSuccessfull = true;
         $user = User::find()->where(['email' => $model->email])->one();
         $user->authKey = uniqid('', TRUE);
         $user->save(false);
         $model->sendForgotPasswordEmail($user);
     }
     return $this->render('forgotPassword', ['model' => $model, 'success' => $isSuccessfull]);
 }
示例#2
0
 public function actionForgotPassword()
 {
     try {
         $model = new ForgotPasswordForm();
     } catch (InvalidParamException $e) {
         return $this->render('opResult', ['title' => '密码重置申请', 'status' => 'warning', 'msg' => $e->getMessage()]);
     }
     if ($model->load(Yii::$app->getRequest()->post()) && $model->validate()) {
         try {
             $model->apply();
             return $this->render('opResult', ['title' => '密码重置申请', 'status' => 'success', 'msg' => '密码重置链接已发送到您的邮箱,请进邮箱确认。']);
         } catch (InvalidParamException $e) {
             Yii::$app->getSession()->setFlash('sendPwdNG', $e->getMessage());
         }
     }
     return $this->render('forgotPassword', ['model' => $model]);
 }