/** * main action */ public function mainAction() { /** * client */ require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); if ($_POST['submit']) { $customer_data = $Customer->getClientByEmail($_POST['client']['customer']['email']); if (is_array($customer_data)) { require_once 'models/common/common_email.php'; $EmailForm = new common_email(); //this allows use customer data and company data in the mail template //is passed as DATA to template in common_email->_format $GLOBALS['common_email']['customer'] = $customer_data; if (!$EmailForm->sendEmail('password_reminder', 'n/a', $customer_data['email'], $customer_data['first_name'] . " " . $customer_data['last_name'])) { msg("Can't send email with password reminder", 'error'); } $this->tpl->parse('content.password_sent'); $hide_form = 1; } } if ($hide_form == 0) { $this->tpl->parse('content.request_form'); } //sanitize before we add HTML attribute checked="checked" :) if (is_array($_POST['client'])) { $this->tpl->assign('CLIENT', $_POST['client']); } return true; }
/** * main action */ public function mainAction() { /** * client */ $Customer = new client_customer(); $Customer->setCacheable(false); if ($_SESSION['client']['customer']['id'] > 0 && !$this->GET['client']['email']) { //msg('you are in'); //onxshopGoTo($this->GET['to']); } else { /* client submitted username/password */ if (isset($_POST['login'])) { $customer_detail = $Customer->login($_POST['client']['customer']['email'], md5($_POST['client']['customer']['password'])); if ($customer_detail) { $_SESSION['client']['customer'] = $customer_detail; if (isset($_POST['autologin'])) { // auto login (TODO allow to enable/disable this behaviour globally) $Customer->generateAndSaveOnxshopToken($customer_detail['id']); } } else { $this->loginFailed(); } } /* log in as client from backoffice */ if (Onxshop_Bo_Authentication::getInstance()->isAuthenticated() && $this->GET['client']['email']) { $customer_detail = $Customer->getClientByEmail($this->GET['client']['email']); if ($customer_detail) { $_SESSION['client']['customer'] = $customer_detail; } else { msg('Login from backoffice failed.', 'error'); } } } /** * check status */ if ($_SESSION['client']['customer']['id'] > 0 && is_numeric($_SESSION['client']['customer']['id'])) { $this->actionAfterLogin(); } //output $this->tpl->assign('CLIENT', $_POST['client']); $this->tpl->parse('content.login_box'); return true; }
/** * processCustomerDetails */ public function processCustomerDetails($form_data) { require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); $customer_details = $Customer->getClientByEmail($form_data['email']); if (is_numeric($customer_details['id'])) { return $Customer->mergePreservedAccount($customer_details, $form_data); } else { return $Customer->insertPreservedCustomer($form_data); } }
/** * main action */ public function mainAction() { /** * initialise client_customer object */ require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); /** * process when submited */ if ($_POST['submit']) { /** * assign first */ if (is_array($_POST['client'])) { $this->tpl->assign('CLIENT', $_POST['client']); } /** * get detail */ $customer_data = $Customer->getClientByEmail($_POST['client']['customer']['email']); /** * when real client, get key */ if (is_array($customer_data)) { $current_key = $Customer->getPasswordKey($_POST['client']['customer']['email']); $customer_data['password_key'] = $current_key; } /** * if key was generated successfully, than send it by email */ if ($current_key) { require_once 'models/common/common_email.php'; $EmailForm = new common_email(); //this allows use customer data and company data in the mail template //is passed as DATA to template in common_email->_format $GLOBALS['common_email']['customer'] = $customer_data; if (!$EmailForm->sendEmail('request_password_change', 'n/a', $customer_data['email'], $customer_data['first_name'] . " " . $customer_data['last_name'])) { msg("Can't send email with request for password reset", 'error'); } $this->tpl->parse('content.request_sent'); $hide_form = 1; } } /** * reset password when valied email and key is provided */ if ($this->GET['email'] && $this->GET['key']) { if ($Customer->resetPassword($this->GET['email'], $this->GET['key'])) { msg("Password for {$this->GET['email']} has for been renewed.", 'ok', 2); $this->tpl->parse('content.password_changed'); $hide_form = 1; } } /** * conditional display form */ if ($hide_form == 0) { $this->tpl->parse('content.request_form'); } return true; }