/** * 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; }
/** * loginToOnxshop */ public function loginToOnxshop($user_profile) { require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); if ($customer_detail = $Customer->getUserByTwitterId($user_profile->id)) { //already exists a valid account, we can login msg("{$customer_detail['email']} is already registered", 'ok', 1); $_SESSION['client']['customer'] = $customer_detail; $_SESSION['use_page_cache'] = false; // auto login (TODO allow to enable/disable this behaviour) $Customer->generateAndSaveOnxshopToken($customer_detail['id']); } else { msg("Twitter ID {$user_profile->id} sucessfully authorised, but must register locally", 'ok', 1); //forward to registration $this->mapUserToOnxshop($user_profile); onxshopGoTo("/page/13"); //TODO get node_id from conf } }