アドレス=/Cake / hybridauth / auth / googleでHybridAuthプラグインを使用してログインし、これらの詳細を使用してデータベースでユーザーを検索し、次のようにデフォルトのCakePHPAuthにログインします。
$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コンポーネントに追加すると、上記のコードは機能しているようです...
私が欠けているアイデアはありますか?
どうもありがとう。