예제 #1
0
 protected function _generatePasswords()
 {
     $save = false;
     $device = $this->getDevice();
     if (!$device->getStorePass()) {
         $device->setStorePass(Core_Model_Lib_String::generate(8));
         $save = true;
     }
     if (!$device->getKeyPass()) {
         $device->setKeyPass(Core_Model_Lib_String::generate(8));
         $save = true;
     }
     if (!$device->getAlias()) {
         $alias = Core_Model_Lib_String::format($this->getApplication()->getName(), true);
         if (!$alias) {
             $alias = $this->getApplication()->getId();
         }
         $device->setAlias($alias);
         $save = true;
     }
     if ($save) {
         $device->save();
     }
     return $this;
 }
예제 #2
0
 public function forgottenpasswordAction()
 {
     if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) {
         try {
             if (empty($data['email'])) {
                 throw new Exception($this->_('Please enter your email address'));
             }
             $user = new Backoffice_Model_User();
             $user->find($data['email'], 'email');
             if (!$user->getId()) {
                 throw new Exception($this->_("Your email address does not exist"));
             }
             $password = Core_Model_Lib_String::generate(8);
             $user->setPassword($password)->save();
             $sender = System_Model_Config::getValueFor("support_email");
             $support_name = System_Model_Config::getValueFor("support_name");
             $layout = $this->getLayout()->loadEmail('admin', 'forgot_password');
             $subject = $this->_('Your new password');
             $layout->getPartial('content_email')->setPassword($password);
             $content = $layout->render();
             $mail = new Zend_Mail('UTF-8');
             $mail->setBodyHtml($content);
             $mail->setFrom($sender, $support_name);
             $mail->addTo($user->getEmail(), $user->getName());
             $mail->setSubject($subject);
             $mail->send();
             $data = array("success" => 1, "message" => $this->_('Your new password has been sent to the entered email address'));
         } catch (Exception $e) {
             $data = array("error" => 1, "message" => $e->getMessage());
         }
     }
     $this->_sendHtml($data);
 }
 public function postAction()
 {
     if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) {
         try {
             if (empty($data['email'])) {
                 throw new Exception($this->_('Please enter your email address'));
             }
             if (!Zend_Validate::is($data['email'], 'EmailAddress')) {
                 throw new Exception($this->_('Please enter a valid email address'));
             }
             $customer = new Customer_Model_Customer();
             $customer->find(array('email' => $data['email'], "app_id" => $this->getApplication()->getId()));
             if (!$customer->getId()) {
                 throw new Exception("Your email address does not exist");
             }
             $admin_email = null;
             $password = Core_Model_Lib_String::generate(8);
             $contact = new Contact_Model_Contact();
             $contact_page = $this->getApplication()->getPage('contact');
             if ($contact_page->getId()) {
                 $contact->find($contact_page->getId(), 'value_id');
                 $admin_email = $contact->getEmail();
             }
             $customer->setPassword($password)->save();
             $sender = 'no-reply@' . Core_Model_Lib_String::format($this->getApplication()->getName(), true) . '.com';
             $layout = $this->getLayout()->loadEmail('customer', 'forgot_password');
             $layout->getPartial('content_email')->setCustomer($customer)->setPassword($password)->setAdminEmail($admin_email)->setApp($this->getApplication()->getName());
             $content = $layout->render();
             $mail = new Zend_Mail('UTF-8');
             $mail->setBodyHtml($content);
             $mail->setFrom($sender, $this->getApplication()->getName());
             $mail->addTo($customer->getEmail(), $customer->getName());
             $mail->setSubject($this->_('%s - Your new password', $this->getApplication()->getName()));
             $mail->send();
             $html = array("success" => 1, "message" => $this->_("Your new password has been sent to the entered email address"));
         } catch (Exception $e) {
             $html = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($html);
     }
     return $this;
 }
예제 #4
0
 public function forgotpasswordAction()
 {
     if ($data = $this->getRequest()->getPost()) {
         try {
             if (empty($data['email'])) {
                 throw new Exception($this->_('Please enter your email address'));
             }
             $admin = new Admin_Model_Admin();
             $admin->findByEmail($data['email']);
             if (!$admin->getId()) {
                 throw new Exception($this->_("This email address does not exist"));
             }
             $password = Core_Model_Lib_String::generate(8);
             $admin->setPassword($password)->save();
             $sender = System_Model_Config::getValueFor("support_email");
             $support_name = System_Model_Config::getValueFor("support_name");
             $layout = $this->getLayout()->loadEmail('admin', 'forgot_password');
             $subject = $this->_('%s - Your new password', $support_name);
             $layout->getPartial('content_email')->setPassword($password);
             $content = $layout->render();
             $mail = new Zend_Mail('UTF-8');
             $mail->setBodyHtml($content);
             $mail->setFrom($sender, $support_name);
             $mail->addTo($admin->getEmail(), $admin->getName());
             $mail->setSubject($subject);
             $mail->send();
             $data = array("success" => 1);
         } catch (Exception $e) {
             $data = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($data);
     }
 }
예제 #5
0
 public function forgotpasswordpostAction()
 {
     if ($datas = $this->getRequest()->getPost() and !$this->getSession()->isLoggedIn('admin') and !$this->getSession()->isLoggedIn('pos')) {
         try {
             if (empty($datas['email'])) {
                 throw new Exception($this->_('Please enter your email address'));
             }
             $admin = new Admin_Model_Admin();
             $admin->findByEmail($datas['email']);
             if (!$admin->getId()) {
                 throw new Exception($this->_("Your email address does not exist"));
             }
             $password = Core_Model_Lib_String::generate(8);
             $admin->setPassword($password)->save();
             $sender = System_Model_Config::getValueFor("support_email");
             $support_name = System_Model_Config::getValueFor("support_name");
             $layout = $this->getLayout()->loadEmail('admin', 'forgot_password');
             $subject = $this->_('%s - Your new password', $support_name);
             $layout->getPartial('content_email')->setPassword($password);
             $content = $layout->render();
             $mail = new Zend_Mail('UTF-8');
             $mail->setBodyHtml($content);
             $mail->setFrom($sender, $support_name);
             $mail->addTo($admin->getEmail(), $admin->getName());
             $mail->setSubject($subject);
             $mail->send();
             $this->getSession()->addSuccess($this->_('Your new password has been sent to the entered email address'));
         } catch (Exception $e) {
             $this->getSession()->addError($e->getMessage());
         }
     }
     $this->_redirect('/');
     return $this;
 }