CakePHP-Facebook-Plugin icon indicating copy to clipboard operation
CakePHP-Facebook-Plugin copied to clipboard

Logout from app only not from facebook

Open andreirebe opened this issue 11 years ago • 13 comments

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.

andreirebe avatar Apr 11 '13 16:04 andreirebe

I have the same problem.

oidacra avatar Apr 11 '13 17:04 oidacra

Me too

mlumbroso avatar Apr 15 '13 14:04 mlumbroso

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.

DColl avatar May 04 '13 08:05 DColl

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

andreirebe avatar May 04 '13 10:05 andreirebe

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

DColl avatar May 04 '13 16:05 DColl

yes

andreirebe avatar May 04 '13 16:05 andreirebe

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

DColl avatar May 04 '13 16:05 DColl

It tells me ConnectComponent does not exist ...

andreirebe avatar May 04 '13 16:05 andreirebe

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

andreirebe avatar May 04 '13 16:05 andreirebe

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 !

DColl avatar May 04 '13 17:05 DColl

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

andreirebe avatar May 04 '13 17:05 andreirebe

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 ;)

DColl avatar May 04 '13 17:05 DColl

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

andreirebe avatar May 04 '13 17:05 andreirebe