示例#1
0
 public function resetpwdAction()
 {
     $request = $this->getRequest();
     $resetKey = $request->getParam('id');
     $registry = Shineisp_Registry::getInstance();
     $translator = $registry->Zend_Translate;
     $customer = Customers::getCustomerByResetKey($resetKey);
     if ($customer) {
         $newPwd = Shineisp_Commons_Utilities::GenerateRandomPassword();
         try {
             // Update the record
             Customers::setCustomerPassword($customer[0]['customer_id'], $newPwd);
             // Force expire of reset link
             Customers::deleteResetPasswordKey($customer[0]['customer_id']);
         } catch (Exception $e) {
             echo $e->getMessage();
             die;
         }
         $customer[0]['password'] = $newPwd;
         // Getting the email template
         Shineisp_Commons_Utilities::sendEmailTemplate($customer[0]['email'], 'password_new', array('fullname' => $customer[0]['lastname'], 'email' => $customer[0]['email'], ':shineisp:' => $customer, 'password' => $newPwd), null, null, null, null, $customer[0]['language_id']);
         $this->view->mextype = "success";
         $this->view->mex = $translator->translate('Email sent');
     } else {
         $this->view->mextype = "alert";
         $this->view->mex = $translator->translate('An error occurred while setting your password. Please try again.');
     }
     return $this->_helper->viewRenderer('password');
 }