webtechnick/CakePHP-Facebook-Plugin — Issue #53: Cannot connect with database
Author: andreirebe
Created: 2012-02-22 19:06:10+00:00
State: open

I am using CakePHP 2.0.5 / OS X 10.6 / MAMP PRO

I can't get it working with the cakephp auth. I followed the video tutorial and I've read the installation tutorial but it does not change anything in the database. When I login with facebook it doesn't execute any query at all. Also it does not show the logout button.

You can see what it displays after login here: http://i43.tinypic.com/144cw94.jpg

What could cause this problems?
If there is anything more that you need to help me please ask.

Thank you in advance.

Here you have come code:

AppController.php

```
class AppController extends Controller {
public $helpers = array('Facebook.Facebook', 'Html', 'Session', 'Form');

public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('admin' => 'false', 'controller' => 'users', 'action' => 'index'),
'logoutRedirect' => array('controller' => 'users', 'action' => 'index'),
'authorize' => array('Controller'),
),
'Facebook.Connect'
);

function beforeFilter() {
$this->Auth->allow('display'); //obligatorie
$this->set('facebook_user', $this->Connect->user());
$this->set('logged_in', $this->_loggedIn());
$this->set('currentUser', $this->Auth->user());
if (isset($this->params['admin']) && $this->params['admin'] == 'admin') {
$this->layout = 'admin';
}
}

function beforeFacebookSave(){
$this->Connect->authUser['User']['email'] = $this->Connect->user('email');
return true; //Must return true or will not save.
}

public function isAuthorized() {
return true;
}

public function _loggedIn(){
$logged_in=FALSE;
if ($this->Auth->user()){
$logged_in=TRUE;
}
return $logged_in;
//!empty($this->Auth->user());
}
}
```

In the view i've put the following code:
```$this->Facebook->login()```

I have also replaced `````` with the next line:
```echo $this->Facebook->html();```

and i've put this line just before ```

```
```echo $this->Facebook->init();```

In the database inside table users i've added a column named facebook_id