public function createPostAction()
 {
     $post = $this->getRequest()->getPost();
     if ($post) {
         $aUser = array();
         $aUser['type'] = 'register';
         $aUser['sender_email'] = isset($post['email']) ? $post['email'] : '';
         $aUser['sender_nickname'] = isset($post['firstname']) ? $post['firstname'] : '';
         $aUser['sender_nickname'] .= isset($post['lastname']) ? ' ' . $post['lastname'] : '';
         $model = Mage::getModel('antispam/api');
         $aResult = $model->CheckSpam($aUser, FALSE);
         if (isset($aResult) && is_array($aResult)) {
             if ($aResult['errno'] == 0) {
                 if ($aResult['allow'] == 0) {
                     if (preg_match('//u', $aResult['ct_result_comment'])) {
                         $comment_str = preg_replace('/^[^\\*]*?\\*\\*\\*|\\*\\*\\*[^\\*]*?$/iu', '', $aResult['ct_result_comment']);
                         $comment_str = preg_replace('/<[^<>]*>/iu', '', $comment_str);
                     } else {
                         $comment_str = preg_replace('/^[^\\*]*?\\*\\*\\*|\\*\\*\\*[^\\*]*?$/i', '', $aResult['ct_result_comment']);
                         $comment_str = preg_replace('/<[^<>]*>/i', '', $comment_str);
                     }
                     Mage::getSingleton('customer/session')->addError($comment_str);
                     //$this->_redirect('*/*/');
                     $this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));
                     return;
                 }
             }
         }
     }
     parent::createPostAction();
 }
 /**
  * Action predispatch
  *
  * Check customer authentication for some actions
  */
 public function preDispatch()
 {
     parent::preDispatch();
     if (!Mage::getSingleton('customer/session')->authenticate($this)) {
         $this->setFlag('', 'no-dispatch', true);
     }
 }
 public function logoutAction()
 {
     $session = Mage::getSingleton("core/session");
     $session->unsPerscriptionCheck();
     $session->unsCartAction();
     return parent::logoutAction();
 }
 /**
  * Action predispatch
  *
  * Check customer authentication for some actions
  */
 public function preDispatch()
 {
     parent::preDispatch();
     if (!Mage::getSingleton('customer/session')->authenticate($this)) {
         $this->setFlag('', self::FLAG_NO_DISPATCH, true);
     }
 }
 public function logoutAction()
 {
     if (isset($_COOKIE['anastasia'])) {
         setcookie('anastasia', '', time() - 60 * 60 * 24 * 7, '/');
     }
     parent::logoutAction();
 }
 /**
  * Customer login form page
  */
 public function loginAction()
 {
     $session = $this->_getSession();
     // Set women category as before URL
     $categoryUrl = Mage::getModel('catalog/category')->load(4)->getUrl();
     $session->setBeforeAuthUrl($categoryUrl);
     parent::loginAction();
 }
 public function preDispatch()
 {
     parent::preDispatch();
     $_726da6d3022af6314a6aa35c59981f2654ef1b69 = $this->getRequest()->getActionName();
     if ($_726da6d3022af6314a6aa35c59981f2654ef1b69 == 'refreshsublogin') {
         $this->_getSession()->setNoReferer(true);
         $this->setFlag('', 'no-dispatch', false);
     }
 }
 /**
  * Overwrite Magento loginAction method,
  * to check if a customer is already logged in
  */
 public function loginAction()
 {
     /* Something went wrong, force login form */
     if ($this->getRequest()->getParam('forceWsoLogin') != true) {
         $samlHelper = Mage::helper('hukmedia_wso2/saml');
         $samlHelper->sendAuthnRequest(null, null, false, true);
     }
     /* No WSO2 session established, start login procedure */
     parent::loginAction();
 }
 public function logoutSuccessAction()
 {
     if (Mage::getBlockSingleton('hostedregistration/hostedregistration')->enableHostedPage() == '1') {
         $islogout = $this->getRequest()->getParam('islogout');
         if ($islogout == 'true') {
             parent::logoutAction();
         }
         parent::logoutSuccessAction();
     } else {
         parent::logoutSuccessAction();
     }
 }
Пример #10
0
 public function createAction()
 {
     if (Mage::getStoreConfig('customer/avectra/login_hook') == 1) {
         $referer = $this->_getRefererUrl() ? $this->_getRefererUrl() : 'https://' . $_SERVER['SERVER_NAME'];
         $return_url = preg_replace('/^http:/', 'https:', $referer);
         $return_url = urlencode($return_url);
         Mage::log($return_url, null, 'cust-account-controller.log');
         Mage::log($this->getSharepointRegister() . '?' . $this->getReturnPathGetParam() . '=' . $return_url, null, 'cust-account-controller.log');
         $this->_redirectUrl($this->getSharepointRegister() . '?' . $this->getReturnPathGetParam() . '=' . $return_url);
     } else {
         parent::createAction();
     }
 }
 /**
  * Default customer account page
  */
 public function preDispatch()
 {
     parent::preDispatch();
     $_loginRedirect = Mage::getStoreConfig('unm/unm_group_2/active', Mage::app()->getStore());
     $_loginRedirectUrl = Mage::getStoreConfig('unm/unm_group_2/redirect_url', Mage::app()->getStore());
     if ($_loginRedirect) {
         if ($this->_getSession()->isLoggedIn()) {
             $customer = Mage::getModel('customer/customer')->load(Mage::getSingleton('customer/session')->getCustomer()->getId());
             if (!$customer->getCompleteSfForm() && !empty($_loginRedirectUrl) && $_SERVER['REQUEST_URI'] != $_loginRedirectUrl) {
                 $this->_redirectUrl($_loginRedirectUrl);
             }
         }
     }
 }
 public function createPostAction()
 {
     $alreadyLoggedin = false;
     $session = $this->_getSession();
     if ($session->isLoggedIn()) {
         $alreadyLoggedin = true;
     }
     parent::createPostAction();
     if ($session->isLoggedIn() && !$alreadyLoggedin) {
         $product_id = $this->getRequest()->getParam('productalert_product');
         if ($product_id != 'hello') {
             $this->stockAction($product_id, '/accessories', true);
         }
     }
 }
Пример #13
0
 /**
  * do not allow to buy more than 1 subscription product
  */
 protected function _loginPostRedirect()
 {
     if (preg_match('/onepage/', $this->_getRefererUrl()) == 1) {
         if (!Mage::getModel('pixsubscription/subscription')->canBuySubscription(Mage::helper('pixopc')->getCartItem())) {
             Mage::getSingleton('core/session')->addError((string) Mage::getConfig()->getNode('default/pixopc/pix_subscription_amount_error_message/message'));
             Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getBaseUrl());
             Mage::app()->getResponse()->sendResponse();
             exit;
         }
     }
     // Save error messages to cookie
     $message = $this->_getSession()->getMessages()->getLastAddedMessage();
     if ($message instanceof Mage_Core_Model_Message_Error) {
         $message_html = $this->getLayout()->createBlock('core/messages')->addMessage($message)->getGroupedHtml();
         setrawcookie("login_messages", rawurlencode($message_html), time() + 300, "/");
     }
     parent::_loginPostRedirect();
 }
 public function createPostAction()
 {
     if (Mage::getStoreConfig("fontis_recaptcha/recaptcha/customer")) {
         // check that recaptcha is actually enabled
         $privatekey = Mage::getStoreConfig("fontis_recaptcha/setup/private_key");
         // check response
         $resp = Mage::helper("fontis_recaptcha")->recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
         if ($resp == true) {
             // if recaptcha response is correct, use core functionality
             parent::createPostAction();
         } else {
             $this->_getSession()->addError($this->__('Your reCAPTCHA entry is incorrect. Please try again.'));
             $this->_getSession()->setCustomerFormData($this->getRequest()->getPost());
             $this->_redirectReferer();
             return;
         }
     } else {
         // if recaptcha is not enabled, use core function
         parent::createPostAction();
     }
 }
 public function createPostAction()
 {
     if (Mage::getStoreConfig("OutsourceOnline_Captcha/captcha/customer")) {
         // check that captcha is actually enabled
         $privatekey = Mage::getStoreConfig("OutsourceOnline_Captcha/setup/private_key");
         // check response
         $resp = Mage::helper("outsourceonline_captcha")->validate();
         //validate botscout
         Mage::helper("outsourceonline_captcha")->validateBotScout(Mage::getSingleton('core/app')->getRequest()->getParam('email'));
         if ($resp == true) {
             // if captcha response is correct, use core functionality
             parent::createPostAction();
         } else {
             $this->_getSession()->addError($this->__('Your CAPTCHA entry is incorrect. Please try again.'));
             $this->_getSession()->setCustomerFormData($this->getRequest()->getPost());
             $this->_redirectReferer();
             return;
         }
     } else {
         // if captcha is not enabled, use core function
         parent::createPostAction();
     }
 }
 public function preDispatch()
 {
     $action = $this->getRequest()->getActionName();
     if (preg_match('/^(' . $this->_getCustomActions() . ')/i', $action)) {
         $this->getRequest()->setActionName($this->_validActions[1]);
     }
     parent::preDispatch();
     /**
      * Parent check is complete, reset request action name to origional value
      */
     if ($action != $this->getRequest()->getActionName()) {
         $this->getRequest()->setActionName($action);
     }
     if (!$this->getRequest()->isDispatched()) {
         return;
     }
     if (!preg_match('/^(' . $this->_getValidActions() . ')/i', $action)) {
         if (!$this->_getSession()->authenticate($this)) {
             $this->setFlag('', 'no-dispatch', true);
         }
     } else {
         $this->_getSession()->setNoReferer(true);
     }
 }
 /**
  * Create customer account action
  */
 public function createPostAction()
 {
     $session = $this->_getSession();
     if ($session->isLoggedIn()) {
         $this->_redirect('*/*/');
         return;
     }
     $isMarketplaceEnabled = Mage::Helper("marketplace")->isMarketplaceEnabled();
     if ($isMarketplaceEnabled == false) {
         return parent::createPostAction();
     }
     $session->setEscapeMessages(true);
     // prevent XSS injection in user input
     if (!$this->getRequest()->isPost()) {
         $errUrl = $this->_getUrl('*/*/create', array('_secure' => true));
         $this->_redirectError($errUrl);
         return;
     }
     $customer = $this->_getCustomer();
     try {
         $errors = $this->_getCustomerErrors($customer);
         if ($this->getRequest()->getParam('check_seller_form')) {
             $customer->setCompanyLocality($this->getRequest()->getPost('company_locality'));
             $customer->setCompanyName($this->getRequest()->getPost('company_name'));
             $customerErrors = Mage::getModel('marketplace/customer')->customValidate($customer);
         }
         if (is_array($customerErrors)) {
             $errors = array_merge($customerErrors, $errors);
         }
         if (empty($errors)) {
             $customer->cleanPasswordsValidationData();
             // saving seller information
             if ($this->getRequest()->getParam('check_seller_form')) {
                 $customerId = $customer->getEntityId();
                 /******************** company banner upload code ******************************** */
                 if (isset($_FILES['company_banner']['name']) && $_FILES['company_banner']['name'] != '') {
                     $fileName = $_FILES['company_banner']['name'];
                     $fieldName = 'company_banner';
                     $companyBanner = $this->_uploadImage($fileName, $fieldName, $customerId);
                     $customer->setCompanyBanner($companyBanner);
                 }
                 /******************* end of company banner code ******************************** */
                 /******************** company logo upload code ******************************** */
                 if (isset($_FILES['company_logo']['name']) && $_FILES['company_logo']['name'] != '') {
                     $fileName = $_FILES['company_logo']['name'];
                     $fieldName = 'company_logo';
                     $companyLogo = $this->_uploadImage($fileName, $fieldName, $customerId);
                     $customer->setCompanyLogo($companyLogo);
                 }
                 /******************* end of company logo code ******************************** */
                 $customer->setCompanyLocality($this->getRequest()->getPost('company_locality'));
                 $customer->setCompanyName($this->getRequest()->getPost('company_name'));
                 $customer->setCompanyDescription($this->getRequest()->getPost('company_description'));
                 $customer->setSellerSubscriber(1);
                 // Auto approval of seller check
                 if (Mage::getStoreConfig('marketplace/marketplace/auto_approval_seller')) {
                     $customer->setStatus(Mage::getStoreConfig('marketplace/status/approved'));
                 } else {
                     $customer->setStatus(Mage::getStoreConfig('marketplace/status/pending'));
                 }
             } else {
                 $customer->setSellerSubscriber(0);
             }
             $customer->save();
             $this->_dispatchRegisterSuccess($customer);
             $this->_successProcessRegistration($customer);
             return;
         } else {
             $this->_addSessionError($errors);
         }
     } catch (Mage_Core_Exception $e) {
         $session->setCustomerFormData($this->getRequest()->getPost());
         if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
             $url = $this->_getUrl('customer/account/forgotpassword');
             $message = $this->__('There is already an account with this email address. If you are sure that it is your email address, <a href="%s">click here</a> to get your password and access your account.', $url);
             $session->setEscapeMessages(false);
         } else {
             $message = $e->getMessage();
         }
         $session->addError($message);
     } catch (Exception $e) {
         $session->setCustomerFormData($this->getRequest()->getPost())->addException($e, $this->__('Cannot save the customer.'));
     }
     $errUrl = $this->_getUrl('*/*/create', array('_secure' => true));
     $this->_redirectError($errUrl);
 }
Пример #18
0
 /**
  * Define target URL and redirect customer after logging in
  * 
  * @see Mage_Customer_AccountController::_loginPostRedirect
  * @since 2014/11/05 use default redirect if login was not successful to avoid error message display is being suppressed by multiple redirects
  */
 protected function _loginPostRedirect()
 {
     $session = $this->_getSession();
     # retrieve xml path constant (ce >= 1.6)
     if (defined('Mage_Customer_Helper_Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD')) {
         $this->xmlPathCustomerStartupRedirectToDashboard = Mage_Customer_Helper_Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD;
     }
     # use default behaviour if privatesales disabled OR login failed OR customer_startup_redirect_dashboard is configured
     if (!Mage::helper('privatesales')->isEnabled() || !$session->isLoggedIn() || Mage::getStoreConfigFlag($this->xmlPathCustomerStartupRedirectToDashboard)) {
         return parent::_loginPostRedirect();
     }
     if (!$session->getBeforeAuthUrl()) {
         #no baseurl comparison here, default logic after here
         # set default URL to redirect customer to
         $session->setBeforeAuthUrl(Mage::helper('customer')->getAccountUrl());
         # redirect customer to the last page visited after logging in
         if ($session->isLoggedIn()) {
             if (!Mage::getStoreConfigFlag($this->xmlPathCustomerStartupRedirectToDashboard)) {
                 $referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME);
                 if ($referer) {
                     $referer = Mage::helper('core')->urlDecode($referer);
                     if ($this->_isUrlInternal($referer)) {
                         $session->setBeforeAuthUrl($referer);
                     }
                 }
             } elseif ($session->getAfterAuthUrl()) {
                 $session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
             }
         } else {
             $session->setBeforeAuthUrl(Mage::helper('customer')->getLoginUrl());
         }
     } elseif ($session->getBeforeAuthUrl() == Mage::helper('customer')->getLogoutUrl()) {
         $session->setBeforeAuthUrl(Mage::helper('customer')->getDashboardUrl());
     } else {
         if (!$session->getAfterAuthUrl()) {
             $session->setAfterAuthUrl($session->getBeforeAuthUrl());
         }
         if ($session->isLoggedIn()) {
             $session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
         }
     }
     # perform redirect
     $this->_redirectUrl($session->getBeforeAuthUrl(true));
 }
Пример #19
0
 /**
  * Create customer account action
  */
 public function createPostAction()
 {
     $session = $this->_getSession();
     if ($session->isLoggedIn()) {
         $this->_redirect('*/*/');
         return;
     }
     $isMarketplaceEnabled = Mage::Helper("marketplace")->isMarketplaceEnabled();
     if ($isMarketplaceEnabled == false) {
         return parent::createPostAction();
     }
     $session->setEscapeMessages(true);
     // prevent XSS injection in user input
     if ($this->getRequest()->isPost()) {
         $errors = array();
         if (!($customer = Mage::registry('current_customer'))) {
             $customer = Mage::getModel('customer/customer')->setId(null);
         }
         /* @var $customerForm Mage_Customer_Model_Form */
         $customerForm = Mage::getModel('customer/form');
         $customerForm->setFormCode('customer_account_create')->setEntity($customer);
         $customerData = $customerForm->extractData($this->getRequest());
         if ($this->getRequest()->getParam('is_subscribed', false)) {
             $customer->setIsSubscribed(1);
         }
         /**
          * Initialize customer group id
          */
         //$customer->getGroupId();
         if ($this->getRequest()->getPost('group_id')) {
             $customer->setGroupId($this->getRequest()->getPost('group_id'));
         } else {
             $customer->getGroupId();
         }
         if ($this->getRequest()->getPost('create_address')) {
             /* @var $address Mage_Customer_Model_Address */
             $address = Mage::getModel('customer/address');
             /* @var $addressForm Mage_Customer_Model_Form */
             $addressForm = Mage::getModel('customer/form');
             $addressForm->setFormCode('customer_register_address')->setEntity($address);
             $addressData = $addressForm->extractData($this->getRequest(), 'address', false);
             $addressErrors = $addressForm->validateData($addressData);
             if ($addressErrors === true) {
                 $address->setId(null)->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
                 $addressForm->compactData($addressData);
                 $customer->addAddress($address);
                 $addressErrors = $address->validate();
                 if (is_array($addressErrors)) {
                     $errors = array_merge($errors, $addressErrors);
                 }
             } else {
                 $errors = array_merge($errors, $addressErrors);
             }
         }
         try {
             $customerErrors = $customerForm->validateData($customerData);
             if ($customerErrors !== true) {
                 $errors = array_merge($customerErrors, $errors);
             } else {
                 $customerForm->compactData($customerData);
                 $customer->setPassword($this->getRequest()->getPost('password'));
                 $customer->setPasswordConfirmation($this->getRequest()->getPost('confirmation'));
                 //var_dump($customer->getData());die;
                 if ($this->getRequest()->getParam('check_seller_form')) {
                     $validationFlag = 1;
                 } else {
                     $validationFlag = 0;
                 }
                 $validationFlag = 1;
                 if ($validationFlag == 1) {
                     $customer->setData($this->getRequest()->getPost());
                     $customerErrors = Mage::getModel('marketplace/customer')->customValidate($customer);
                 }
                 $customerErrors = $customer->validate();
                 if (is_array($customerErrors)) {
                     $errors = array_merge($customerErrors, $errors);
                 }
             }
             $validationResult = count($errors) == 0;
             if (true === $validationResult) {
                 $customer->save();
                 Mage::dispatchEvent('customer_register_success', array('account_controller' => $this, 'customer' => $customer));
                 $validationFlag = 0;
                 // saving seller information
                 if ($this->getRequest()->getParam('check_seller_form')) {
                     $customerId = $customer->getEntityId();
                     /******************** company banner upload code ******************************** */
                     if (isset($_FILES['company_banner']['name']) && $_FILES['company_banner']['name'] != '') {
                         $fileName = $_FILES['company_banner']['name'];
                         $fieldName = 'company_banner';
                         $companyBanner = $this->_uploadImage($fileName, $fieldName, $customerId);
                         $customer->setCompanyBanner($companyBanner);
                     }
                     /******************* end of company banner code ******************************** */
                     /******************** company logo upload code ******************************** */
                     if (isset($_FILES['company_logo']['name']) && $_FILES['company_logo']['name'] != '') {
                         $fileName = $_FILES['company_logo']['name'];
                         $fieldName = 'company_logo';
                         $companyLogo = $this->_uploadImage($fileName, $fieldName, $customerId);
                         $customer->setCompanyLogo($companyLogo);
                     }
                     /******************* end of company logo code ******************************** */
                     $customer->setCompanyLocality($this->getRequest()->getPost('company_locality'));
                     $customer->setCompanyName($this->getRequest()->getPost('company_name'));
                     $customer->setCompanyDescription($this->getRequest()->getPost('company_description'));
                     $customer->setSellerSubscriber(1);
                     // Auto approval of seller check
                     if (Mage::getStoreConfig('marketplace/marketplace/auto_approval_seller')) {
                         $customer->setStatus(Mage::getStoreConfig('marketplace/status/approved'));
                     } else {
                         $customer->setStatus(Mage::getStoreConfig('marketplace/status/pending'));
                     }
                     $validationFlag = 1;
                 } else {
                     $customer->setSellerSubscriber(0);
                 }
                 if ($customer->isConfirmationRequired()) {
                     Mage::getModel('marketplace/customer')->sendNewAccountEmail('confirmation', $session->getBeforeAuthUrl(), Mage::app()->getStore()->getId());
                     $session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.', Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())));
                     $this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure' => true)));
                     return;
                 } else {
                     $session->setCustomerAsLoggedIn($customer);
                     $url = $this->_welcomeCustomer($customer);
                     $this->_redirectSuccess($url);
                     return;
                 }
             } else {
                 $session->setCustomerFormData($this->getRequest()->getPost());
                 if (is_array($errors)) {
                     foreach ($errors as $errorMessage) {
                         $session->addError($errorMessage);
                     }
                 } else {
                     $session->addError($this->__('Invalid customer data'));
                 }
             }
         } catch (Mage_Core_Exception $e) {
             $session->setCustomerFormData($this->getRequest()->getPost());
             if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
                 $url = Mage::getUrl('customer/account/forgotpassword');
                 $message = $this->__('There is already an account with this email address. If you are sure that it is your email address, <a href="%s">click here</a> to get your password and access your account.', $url);
                 $session->setEscapeMessages(false);
             } else {
                 $message = $e->getMessage();
             }
             $session->addError($message);
         } catch (Exception $e) {
             $session->setCustomerFormData($this->getRequest()->getPost())->addException($e, $this->__('Cannot save the customer.'));
         }
     }
     $this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));
 }
 /**
  * Create customer account action
  */
 public function createPostAction()
 {
     try {
         $invitation = $this->_initInvitation();
         $customer = Mage::getModel('customer/customer')->setId(null)->setSkipConfirmationIfEmail($invitation->getEmail());
         Mage::register('current_customer', $customer);
         if ($groupId = $invitation->getGroupId()) {
             $customer->setGroupId($groupId);
         }
         parent::createPostAction();
         if ($customerId = $customer->getId()) {
             $invitation->accept(Mage::app()->getWebsite()->getId(), $customerId);
             Mage::dispatchEvent('enterprise_invitation_customer_accepted', array('customer' => $customer, 'invitation' => $invitation));
         }
         return;
     } catch (Mage_Core_Exception $e) {
         $_definedErrorCodes = array(Enterprise_Invitation_Model_Invitation::ERROR_CUSTOMER_EXISTS, Enterprise_Invitation_Model_Invitation::ERROR_INVALID_DATA);
         if (in_array($e->getCode(), $_definedErrorCodes)) {
             $this->_getSession()->addError($e->getMessage())->setCustomerFormData($this->getRequest()->getPost());
         } else {
             if (Mage::helper('customer')->isRegistrationAllowed()) {
                 $this->_getSession()->addError(Mage::helper('enterprise_invitation')->__('Your invitation is not valid. Please create an account.'));
                 $this->_redirect('customer/account/create');
                 return;
             } else {
                 $this->_getSession()->addError(Mage::helper('enterprise_invitation')->__('Your invitation is not valid. Please contact us at %s.', Mage::getStoreConfig('trans_email/ident_support/email')));
                 $this->_redirect('customer/account/login');
                 return;
             }
         }
     } catch (Exception $e) {
         $this->_getSession()->setCustomerFormData($this->getRequest()->getPost())->addException($e, Mage::helper('customer')->__('Unable to save the customer.'));
     }
     $this->_redirectError('');
     return $this;
 }
 /**
  * Action postdispatch
  *
  * Remove No-referer flag from customer session after each action
  */
 public function postDispatch()
 {
     parent::postDispatch();
     $this->_getSession()->unsNoReferer(false);
 }
 public function forgotPasswordPostAction()
 {
     $params = $this->getRequest()->getParams();
     if (isset($params['le_ajaxlogin']) && $params['le_ajaxlogin']) {
         $email = (string) $this->getRequest()->getPost('email');
         if ($email) {
             $success = false;
             $message = '';
             $error_type = '';
             $error = false;
             if (isset($params['captcha'])) {
                 $_captcha = Mage::getModel('customer/session')->getData('le_captcha_forgotpass_word');
                 if ($_captcha['data'] != $params['captcha']['le_captcha_forgotpass']) {
                     $message = Mage::helper('ajaxlogin')->__('Incorrect CAPTCHA.');
                     $error_type = 'captcha';
                     $error = true;
                 }
             }
             if ($error == false) {
                 $customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email);
                 if ($customer->getId()) {
                     try {
                         $newResetPasswordLinkToken = Mage::helper('customer')->generateResetPasswordLinkToken();
                         $customer->changeResetPasswordLinkToken($newResetPasswordLinkToken);
                         $customer->sendPasswordResetConfirmationEmail();
                         $success = true;
                         $message = Mage::helper('customer')->__('If there is an account associated with %s you will receive an email with a link to reset your password.', Mage::helper('customer')->htmlEscape($email));
                     } catch (Exception $exception) {
                         $message = $exception->getMessage();
                     }
                 } else {
                     $message = Mage::helper('customer')->__('If there is an account associated with %s you will receive an email with a link to reset your password.', Mage::helper('customer')->htmlEscape($email));
                     $error_type = 'email';
                 }
             }
             $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array('success' => $success, 'message' => $message, 'error_type' => $error_type)));
         }
     } else {
         return parent::forgotPasswordPostAction();
     }
 }
Пример #23
0
	protected function _loginPostRedirect() {
		$session = $this->_getSession();
		if ($session->isLoggedIn()) {
			if ($profile = Mage::getSingleton('engage/session')->getIdentifier()) {
				$customer = $session->getCustomer();
				Mage::helper('engage/identifiers')
						->save_identifier($customer->getId(), $profile);
				Mage::getSingleton('engage/session')->setIdentifier(false);
			}
		}

		parent::_loginPostRedirect();
	}
Пример #24
0
 public function indexAction()
 {
     parent::indexAction();
 }
Пример #25
0
 public function editPostAction()
 {
     parent::editPostAction();
     //if($this->getRequest()->getPost('save_type') == 1){
     $cust_type = $this->getRequest()->getPost('cust_type');
     $company = $this->getRequest()->getPost('buscompany');
     $customer = Mage::getSingleton('customer/session')->getCustomer();
     if ($cust_type == 'business' && $this->getRequest()->getPost('save_type') == 1 || $cust_type == 'business' && Mage::getModel('docupload/docupload')->getLastDocumentchk() == 0) {
         //echo "mmmmmmmm"; exit;
         if ($_FILES['businessfile']['size'] > 5242880) {
             Mage::getSingleton('customer/session')->addError('Please upload file size 5MB max.');
             $this->_redirect('*/*/');
             return;
         }
         if (isset($_FILES['businessfile']['name']) && $_FILES['businessfile']['name'] != '') {
             try {
                 // 				$customer = Mage::getSingleton('customer/session')->getCustomer();
                 $path = Mage::getBaseDir() . DS . 'customer_business_doc' . DS;
                 //desitnation directory
                 $archpath = Mage::getBaseDir() . DS . 'customer_business_doc' . DS . 'archieves' . DS;
                 $fname = $_FILES['businessfile']['name'];
                 //file name
                 $uploader = new Varien_File_Uploader('businessfile');
                 //load class
                 $uploader->setAllowedExtensions(array('doc', 'pdf', 'odt', 'docx', 'png', 'jpeg', 'jpg', 'tiff'));
                 //Allowed extension for file
                 $uploader->checkMimeTypeCustom(array('application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/pdf', 'application/vnd.oasis.opendocument.text', 'image/png', 'image/jpeg', 'image/tiff'));
                 //$uploader->setAllowCreateFolders(true); //for creating the directory if not exists
                 $uploader->setAllowRenameFiles(true);
                 //if true, uploaded file's name will be changed, if file with the same name already exists directory.
                 $uploader->setFilesDispersion(false);
                 $output = $uploader->save($path, $fname);
                 //save the file on the specified path
                 //print_r($output); exit;
                 $model = Mage::getModel('docupload/docupload');
                 $model->setUserId($customer->getId());
                 $model->setName($customer->getFirstname() . ' ' . $customer->getLastname());
                 $model->setFilename($output['file']);
                 $model->setNewDocs(1);
                 $model->setDocumentType($this->getRequest()->getPost('docu_type'));
                 $model->setOwnershipType($this->getRequest()->getPost('owner-type'));
                 $model->setNatureOfBusiness($this->getRequest()->getPost('business-nature'));
                 $model->save();
                 $emailSend = 0;
                 if ($customer->getZiscorporate() == 813) {
                     $emailSend = 1;
                 }
                 $customer->setZiscorporate(816);
                 $customer->setCompany($company);
                 $customer->save();
                 if ($emailSend && $customer->getId() > 0) {
                     $customer->sendSmeUpgradeEmail();
                 }
                 Mage::getSingleton('customer/session')->addSuccess('File uploaded successfully and your verification is pending from zoffio side.');
                 $collection = Mage::getModel('docupload/docupload')->getCollection()->addFieldToFilter('user_id', $customer->getId())->setOrder('id', 'DESC');
                 if (count($collection->getData()) > 1) {
                     $i = 1;
                     foreach ($collection as $doc) {
                         if ($i > 1) {
                             $model = Mage::getModel('docupload/docupload')->load($doc->getId());
                             $model->setNewDocs(0);
                             $model->save();
                         }
                         $filename = $doc->getFilename();
                         if ($fname != $filename) {
                             if ($i > 1) {
                                 if (copy($path . $filename, $archpath . $filename)) {
                                     $delete[] = $path . $filename;
                                 }
                                 foreach ($delete as $file) {
                                     unlink($file);
                                 }
                             }
                             if ($i >= 5) {
                                 unlink($archpath . $filename);
                             }
                         }
                         $i++;
                     }
                 }
                 //echo $output['file']; exit;
             } catch (Exception $e) {
                 //echo 'Error Message: '.$e->getMessage();
                 //Mage::throwException('Error Message: '.$e->getMessage());
                 Mage::getSingleton('customer/session')->addError($e->getMessage());
                 $this->_redirect('*/*/');
                 return;
             }
         } else {
             if ($_FILES['businessfile']['name'] == "") {
                 //customer error messages for maker and approver
                 $makerModel = Mage::getModel('makerchecker/MakerChecker');
                 if ($customer->getZmyapprover() == "") {
                     $doc_error = "Please upload file.";
                 }
                 Mage::getSingleton('customer/session')->addError($doc_error);
                 $this->_redirect('*/*/');
                 return;
             }
         }
     } else {
         if ($cust_type == "individual") {
             $resource = Mage::getSingleton('core/resource');
             $readConnection = $resource->getConnection('core_read');
             $customer = Mage::getSingleton('customer/session')->getCustomer();
             $query = "SELECT id FROM docupload WHERE user_id ='" . $customer->getId() . "' ORDER BY id DESC LIMIT 1";
             //echo $query; exit;
             $id = $readConnection->fetchOne($query);
             $model = Mage::getModel('docupload/docupload')->load($id);
             $model->setStatus(2);
             $model->save();
             $customer->setZiscorporate(813);
             $customer->save();
         }
     }
     //Fix MakerChecker issue
     Mage::dispatchEvent('customer_save_save_after', array('customer' => $customer));
     //}
 }
Пример #26
0
 /**
  * Change customer password action
  */
 public function editPostAction()
 {
     if (Mage::helper('cminds_multiuseraccounts')->hasWritePermission()) {
         return parent::editPostAction();
     }
     $this->_getSession()->addError('You Don\'t have permission for this action');
     return $this->_redirect('*/*/');
 }
Пример #27
0
 /**
  * Create customer account action
  */
 public function createPostAction()
 {
     if (Mage::getStoreConfig('fastregistration/general/enabled')) {
         $session = $this->_getSession();
         if ($session->isLoggedIn()) {
             $this->_redirect('*/*/');
             return;
         }
         $session->setEscapeMessages(true);
         // prevent XSS injection in user input
         if ($this->getRequest()->isPost()) {
             $errors = array();
             if (!($customer = Mage::registry('current_customer'))) {
                 $customer = Mage::getModel('customer/customer')->setId(null);
             }
             /* @var $customerForm Mage_Customer_Model_Form */
             $customerForm = Mage::getModel('customer/form');
             $customerForm->setFormCode('customer_account_create')->setEntity($customer);
             $customerData = $customerForm->extractData($this->getRequest());
             /**
              * Initialize customer group id
              */
             $customer->getGroupId();
             $password = $this->getRequest()->getPost('password');
             if (!Mage::getStoreConfig('fastregistration/general/show_password')) {
                 $password = Mage::helper('core')->getRandomString(8, Mage_Core_Helper_Data::CHARS_PASSWORD_LOWERS . Mage_Core_Helper_Data::CHARS_PASSWORD_UPPERS . Mage_Core_Helper_Data::CHARS_PASSWORD_DIGITS . Mage_Core_Helper_Data::CHARS_PASSWORD_SPECIALS);
             }
             try {
                 $customerErrors = $customerForm->validateData($customerData);
                 if ($customerErrors !== true) {
                     $errors = array_merge($customerErrors, $errors);
                 } else {
                     $customerForm->compactData($customerData);
                     $customer->setPassword($password);
                     $customer->setConfirmation($password);
                 }
                 $validationResult = count($errors) == 0;
                 if (true === $validationResult) {
                     $customer->save();
                     Mage::dispatchEvent('customer_register_success', array('account_controller' => $this, 'customer' => $customer));
                     if ($customer->isConfirmationRequired()) {
                         $customer->sendNewAccountEmail('confirmation', $session->getBeforeAuthUrl(), Mage::app()->getStore()->getId());
                         $session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.', Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())));
                         $this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure' => true)));
                         return;
                     } else {
                         $session->setCustomerAsLoggedIn($customer);
                         $url = $this->_welcomeCustomer($customer);
                         $this->_redirectSuccess($url);
                         return;
                     }
                 } else {
                     $session->setCustomerFormData($this->getRequest()->getPost());
                     if (is_array($errors)) {
                         foreach ($errors as $errorMessage) {
                             $session->addError($errorMessage);
                         }
                     } else {
                         $session->addError($this->__('Invalid customer data'));
                     }
                 }
             } catch (Mage_Core_Exception $e) {
                 $session->setCustomerFormData($this->getRequest()->getPost());
                 if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
                     $url = Mage::getUrl('customer/account/forgotpassword');
                     $message = $this->__('There is already an account with this email address. If you are sure that it is your email address, <a href="%s">click here</a> to get your password and access your account.', $url);
                     $session->setEscapeMessages(false);
                 } else {
                     $message = $e->getMessage();
                 }
                 $session->addError($message);
             } catch (Exception $e) {
                 $session->setCustomerFormData($this->getRequest()->getPost())->addException($e, $this->__('Cannot save the customer.'));
             }
         }
         $this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));
     } else {
         parent::createPostAction();
     }
 }
Пример #28
0
 public function preDispatch()
 {
     $this->_url = Mage::getBaseUrl() . '?yregister';
     parent::preDispatch();
 }