我有一个使用本地登录系统的应用程序。我想要做的是允许用户将他们的Facebook帐户连接到他们的帐户。我使用Zend Auth作为我的主要本地登录和Michael Krotscheck的facebook认证。
我可以很好地连接到facebook,但因为我使用的是Zend_Auth,因此facebook数据已经过了主要的本地登录存储。我需要的只是用户的电子邮件和Facebook ID,并将它们插入我的用户表。
下面的代码显示了它是如何工作的,我不知道使用Zend Auth进行facebook登录的另一种选择。有人有同样的问题吗?建议会非常有用。
$auth = Zend_Auth::getInstance();
$adapter = $this->_getFacebookAdapter();
$result = $auth->authenticate($adapter);
if ($result->isValid()) {
$toStore = array('identity' => $auth->getIdentity());
// for facebook
$msgs = $result->getMessages();
$toStore['properties'] = (array) $msgs['user'];
$toStore['provider'] = "facebook";
$auth->getStorage()->write($toStore);
$this->_helper->FlashMessenger('Successful authentication');
//return $this->_redirect('/index/index');
// Check if the User is in our dB
//$users = new My_Model_Users();
//$userTrue = $users->checkUserExists($userId,$providerName);
Zend_Debug::dump($toStore);
Zend_Debug::dump($this->_helper->user());
} else {
$this->_helper->FlashMessenger('Failed authentication');
$this->_helper->FlashMessenger($result->getMessages());
//return $this->_redirect('/index/index');
}
Ĵ
答案 0 :(得分:0)
经过更多拖网堆栈流程后,我找到了解决方案。
Multiple Instances (2) of Zend_Auth
基本上创建了我自己的Auth类并删除了Zend_Auth中的单例模式,这允许我创建另一个实例。
Ĵ