【问题标题】:Cakephp 2.1 Facebook Connect And AuthCakephp 2.1 Facebook 连接和验证
【发布时间】:2012-07-24 14:30:35
【问题描述】:

我在我的应用程序中使用以下插件来让 facebook connect 与 auth 一起工作。

https://github.com/webtechnick/CakePHP-Facebook-Plugin

问题是我想手动将用户数据保存到用户表中。

所以我就这样尝试

public function beforeFacebookSave(){
//$this->Auth->autoRedirect = false;
debug($this->Connect->user('email'));
$this->Connect->authUser['User']['email'] = $this->Connect->user('email');
$this->Connect->authUser['User']['username'] = $this->Connect->user('username');
//Must return true or will not save.
$this->redirect(array('controller' => 'users', 'action' => 'beforefbsave', '?' => array('param1' => $this->Connect->user('email')))); 
//return true;

}

重定向进入循环并出现错误

The page isn't redirecting properly

这是一种正确的方法还是已经按照其他方法来完成这项工作?

【问题讨论】:

  • 你能显示“beforefbsave”的代码吗?
  • @Guilhereme:它来自插件,我能够正确地弄清楚:(

标签: facebook authentication cakephp-2.1


【解决方案1】:

页面上有一个文档: https://github.com/webtechnick/CakePHP-Facebook-Plugin

beforeFacebookSave 处理将用户保存到用户表中。如果返回 false,则创建被拖拽。

//Add an email field to be saved along with creation.
function beforeFacebookSave(){
    $this->Connect->authUser['User']['email'] = $this->Connect->user('email');
    return true; //Must return true or will not save.
}

如果我是你,我会看下一部分:

beforeFacebookLogin 在用户登录 Auth 之前处理用户。

function beforeFacebookLogin($user){
    //Logic to happen before a facebook login
}

使用模型中的直接函数代替重定向。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-10
    • 2015-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多