webtechnick / CakePHP-Facebook-Plugin

CakePHP Facebook Plugin
http://facebook.webtechnick.com
445 stars 138 forks source link

Logout from app only not from facebook #131

Open andreirebe opened 11 years ago

andreirebe commented 11 years ago

I would really like some solution to this problem. I tried every possible way to logout only from my app and not from facebook and I did not found a solution. Someone said that noAuth should be set to true, but if I set noAuth to true then I cannot login anymore (it just refreshes the page with no login no nothing it's just like the button has not been clicked)

A very big thank you in advance to anyone who can share the answer to this question.

oidacra commented 11 years ago

I have the same problem.

mlumbroso commented 11 years ago

Me too

DColl commented 11 years ago

I believe it would be easier if you described in a concrete way "why" (what's the logic behind this behavior) you want to be logged out of your app and not from facebook.

Until then, have you tried putting a link /users/logout which would be something like

    public function logout() {
        $this->Auth->logout();
        $this->Session->destroy();
        $this->redirect('/');
    }

Problem is that Connect component will probably relog your user automagically when he comes back to your app. Sooo.. you can be logged out of your app as long as you don't return to it after the call to /user/logout.

andreirebe commented 11 years ago

It does not work. And I have never seen a site that does not offer logout from the app only.

DColl commented 11 years ago

Ok, so you're speaking of a site, not an inside-facebook app right ?

andreirebe commented 11 years ago

yes

DColl commented 11 years ago

Have you tried using the connect component only from the UserController ? Even directly from the login action

public function login(){
    $this->set('facebookUser', $this->Connect->user()); //or whatever the use you make
}

I may have spelled the call to the component wrong..

andreirebe commented 11 years ago

It tells me ConnectComponent does not exist ...

andreirebe commented 11 years ago

I even tried it to put it in $components under users controller

DColl commented 11 years ago

On the fly would be done like this :

$this->Connect = $this->Components->load('Facebook.Connect', array('model' => 'User'));
$this->Connect->initialize($this);
    $this->set('facebookUser', $this->Connect->user());

But loading it in the $components array is still much simpler. Don't forget to add the other components you normally need !

andreirebe commented 11 years ago

Yes, no more error but now I cannot login anymore. I can login only with my site username/password. If I try with facebook I only get an page refresh

DColl commented 11 years ago

the login dialog must redirect to the controller/action where ConnectComponent is activated. Not sure how to do this, but check the possible settings in the facebookhelper->login()

Keep us posted on your advancement ;)

andreirebe commented 11 years ago

The actual redirect is not the problem. I can make it redirect wherever I want. But it does not log me in.