cakephp登录整个网站

时间:2012-07-21 15:31:41

标签: php session cakephp authentication oauth

我正在使用地址= / cake / hybridauth / auth / google上的HybridAuth插件登录,然后我使用这些详细信息在数据库中查找用户并将其登录到默认的CakePHP Auth之类这样:

   $hybridauth = new Hybrid_Auth($hybridauth_config);
   $adapter = $hybridauth->authenticate($provider);
   $userprofile = $adapter->getUserProfile();
    //look up user + register if not found

        $this->loadModel('User');

        $isUser = $this->User->find('first', array(
                    'conditions' => array(
                        'User.provider' => strtolower($provider),
                        'User.identifier' => $userprofile->identifier
                    ),
                    'callbacks' => true
                ));

        if(!$isUser){
            //register the user
        } else {
            //update user with new credentials
            $this->Auth->login($isUser["User"]);

            //this doesn't work across the whole site, 
            //only this controller's "action" page
        }

一切正常,直到我回到我的主页/ cake /,似乎没有认出我已经登录 - 虽然在控制器的操作页面(cake / hybridauth / auth / google)我有用户登录到Auth组件,上面的代码似乎工作...

任何想法,我都缺少吗?

非常感谢。

0 个答案:

没有答案