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

Logout not working

Open cduarte opened this issue 13 years ago • 3 comments

I use this, but dont work:

Facebook->logout( array('redirect' => array('controller' => 'users', 'action' => 'logout', 'panel' => true) )); ?>

Using cakephp 1.3 Login function working perfectly.

Thanks.

cduarte avatar Feb 11 '12 05:02 cduarte

Same problem.

samuelsimoes avatar Feb 26 '12 20:02 samuelsimoes

Update logout function in /views/helper/facebook.php to the following:

function logout($options = array(), $label = ''){ $options = array_merge( array( 'autologoutlink' => 'true', 'label' => 'Sign Out', 'custom' => false ), $options ); if(isset($options['redirect']) || $options['custom']){ if(isset($options['redirect']) && $options['redirect']){ $options['redirect'] = Router::url($options['redirect']); $response = "window.location = '{$options['redirect']}';"; } else { $response = "window.location.reload();"; } $onclick = "fbLogout();";

        $scriptblock .= $this->Html->scriptBlock(

<<<JS function fbLogout(){ if(typeof FB.logout == 'function'){ if (FB.getAuthResponse()) { FB.logout(function(response) { $response }); return; }
};

$response 
return;  

} JS , array());

        if(isset($options['confirm'])){
            $onclick = 'if(confirm("'.$options['confirm'].'")){'.$onclick.'}';
        }
        if(!empty($label)){
            $options['label'] = $label;
        }
        return $scriptblock.$this->Html->link($options['label'], '#', array('onclick' => $onclick));
    } else {
        unset($options['label'], $options['escape'], $options['custom']);
        return $this->__fbTag('fb:login-button', $label, $options);
    }
}

sacbhatia avatar Mar 20 '12 14:03 sacbhatia

@sacbhatia One minor correction


function logout($options = array(), $label = ''){ $options = array_merge( array( 'autologoutlink' => 'true', 'label' => 'Sign Out',


to


function logout($options = array(), $label = ''){ $options = array_merge( array( 'autologoutlink' => 'true', 'label' => $option, // will assign the text to link per parameter


amjithps avatar Apr 13 '12 11:04 amjithps