예제 #1
0
 /**
  * checkCookieForToken
  */
 protected function checkCookieForToken()
 {
     if (isset($_COOKIE['onxshop_token'])) {
         require_once 'models/client/client_customer_token.php';
         $Token = new client_customer_token();
         $Token->setCacheable(false);
         $customer_detail = $Token->getCustomerDetailForToken($_COOKIE['onxshop_token']);
         if ($customer_detail) {
             require_once 'models/client/client_customer.php';
             $Customer = new client_customer();
             $Customer->setCacheable(false);
             $conf = $Customer::initConfiguration();
             if ($conf['login_type'] == 'username') {
                 $username = $customer_detail['username'];
             } else {
                 $username = $customer_detail['email'];
             }
             $customer_detail = $Customer->login($username);
             if ($customer_detail) {
                 $_SESSION['client']['customer'] = $customer_detail;
                 $_SESSION['use_page_cache'] = false;
             } else {
                 msg('Autologin failed', 'error', 1);
             }
         } else {
             msg('Invalid autologin token supplied', 'error', 1);
             //delete cookie
             setcookie('onxshop_token', '', time() - 3600, '/');
         }
     }
 }
예제 #2
0
 /**
  * invalidate token
  */
 public function invalidateToken()
 {
     // invalidate token in database
     if (isset($_COOKIE['onxshop_token'])) {
         require_once 'models/client/client_customer_token.php';
         $Token = new client_customer_token();
         $Token->setCacheable(false);
         $Token->invalidateToken($_COOKIE['onxshop_token']);
     }
     // invalidate token in cookie
     setcookie("onxshop_token", "", time() - 60 * 60 * 24 * 100, "/");
 }
예제 #3
0
 /**
  * generateAndSaveOnxshopToken
  */
 public function generateAndSaveOnxshopToken($customer_id)
 {
     require_once 'models/client/client_customer_token.php';
     $Token = new client_customer_token();
     $Token->setCacheable(false);
     $token = $Token->generateToken($customer_id);
     if ($token) {
         setcookie("onxshop_token", $token, time() + 3600 * 24 * 600, "/");
         return true;
     } else {
         return false;
     }
 }