TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Single log-on for Kohana and Prestashop
  • Hi all,

    As the subject implies I want to be able to have a single log-on for my Kohana application and the application shop that uses prestashop. So essentially if someone is logged in on the main site and navigates to the shop they are automatically logged into the shop and vice versa.

    I was wondering if anyone in the community has done this before, or can provide some pointers as to how to start going about it. I'm using Kohana 3.2.0.

    Thanks..

  • Main site located at mainsite.com and shop.mainsite.com. I have copied Blowfish.php to app/vendor/PrestaShop/ and made symlink to settings.inc.php to the same folder. After in user/login action after post validation: $customer = ORM::factory('customer')->where('email','=',$post['username'])->and_where('passwd','=',md5(COOKIE_KEY.$post['password']))->find(); // echo md5(COOKIE_KEY.$post['password']); // If ok auth if($customer->loaded()){ if($customer->active>0){ // Do auth stuff if($customer->auth()){ Request::current()->redirect('/'.I18n::lang().'/user/profile'); }else{ $post->error('username', 'cookie_problem'); } }else{ $post->error('username', 'not_activated'); } }else{

                    $post->error('username', 'not_exist');
                }
    

    and in Customer_Model/auth method: public function auth(){ // By default shop id is 1 $cookie_name = md5(PS_VERSION.'ps-s1'); $cookie = ''; $cookie_content = array( 'id_customer'=>$this->id_customer, 'customer_lastname'=>$this->lastname, 'customer_firstname'=>$this->firstname, 'logged'=>1, 'is_guest'=>$this->is_guest, 'passwd'=>$this->passwd, 'email'=>$this->email, ); // include Kohana::find_file("vendor", "Prestashop/Blowfish"); $cryptool = new Blowfish(COOKIE_KEY, COOKIE_IV);

        foreach ($cookie_content as $key => $value) {
            $cookie.= $key.'|'.$value.'¤';
        }
    
        $cookie .= 'checksum|'.crc32(_COOKIE_IV_.$cookie);
    
        $value = $cryptool->encrypt($cookie);
        // echo $cookie_name.'='.$value;exit;
        return setcookie($cookie_name, $value, time() + 1728000, '/', '.'.str_replace('www.', '', Request::current()->headers('host')), 0, true);
    }
    

    Maybe it helps someone :)

  • @jandosul It's not work or you adds not all code. Checking activation should be in model and not controller\action

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion