1
votes

I'm using the below plugin in my app to get facebook connect working with auth.

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

The thing is I want to save user data into users table manually.

So I'm trying like this

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 redirect is getting into a loop and getting an error

The page isn't redirecting properly

Is this a proper way or have follow some other method to get this done?

1
Chan you show the code of "beforefbsave" ? - Guilherme Torres Castro
@Guilhereme: its from the plugin, I was able to figure it out properly :( - Vijay

1 Answers

0
votes

there is a documentation on page: https://github.com/webtechnick/CakePHP-Facebook-Plugin

beforeFacebookSave handle the user to save into the users table. If returned false, creation is haulted.

//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.
}

so if i were you i' d look on the next section:

beforeFacebookLogin Handle the user before logging the user into Auth.

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

and instead of redirection use direct functions from your model.