Facebook SSO - Log the user out of Facebook when s/he logs out of StatusNet
This commit is contained in:
parent
764a297383
commit
5ea0461145
@ -68,7 +68,6 @@ class FacebookSSOPlugin extends Plugin
|
|||||||
*/
|
*/
|
||||||
function initialize()
|
function initialize()
|
||||||
{
|
{
|
||||||
common_debug("XXXXXXXXXXXX " . $this->appId);
|
|
||||||
// Check defaults and configuration for application ID and secret
|
// Check defaults and configuration for application ID and secret
|
||||||
if (empty($this->appId)) {
|
if (empty($this->appId)) {
|
||||||
$this->appId = common_config('facebook', 'appid');
|
$this->appId = common_config('facebook', 'appid');
|
||||||
@ -79,7 +78,6 @@ class FacebookSSOPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->facebook)) {
|
if (empty($this->facebook)) {
|
||||||
common_debug('instantiating facebook obj');
|
|
||||||
$this->facebook = new Facebook(
|
$this->facebook = new Facebook(
|
||||||
array(
|
array(
|
||||||
'appId' => $this->appId,
|
'appId' => $this->appId,
|
||||||
@ -89,8 +87,6 @@ class FacebookSSOPlugin extends Plugin
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
common_debug("FACEBOOK = " . var_export($this->facebook, true));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +239,7 @@ class FacebookSSOPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add a tab for managing Facebook Connect settings
|
* Add a tab for user-level Facebook settings
|
||||||
*
|
*
|
||||||
* @param Action &action the current action
|
* @param Action &action the current action
|
||||||
*
|
*
|
||||||
@ -254,13 +250,14 @@ class FacebookSSOPlugin extends Plugin
|
|||||||
if ($this->hasApplication()) {
|
if ($this->hasApplication()) {
|
||||||
$action_name = $action->trimmed('action');
|
$action_name = $action->trimmed('action');
|
||||||
|
|
||||||
$action->menuItem(common_local_url('facebooksettings'),
|
$action->menuItem(
|
||||||
// @todo CHECKME: Should be 'Facebook Connect'?
|
common_local_url('facebooksettings'),
|
||||||
// TRANS: Menu item tab.
|
// TRANS: Menu item tab.
|
||||||
_m('MENU','Facebook'),
|
_m('MENU','Facebook'),
|
||||||
// TRANS: Tooltip for menu item "Facebook".
|
// TRANS: Tooltip for menu item "Facebook".
|
||||||
_m('Facebook Connect Settings'),
|
_m('Facebook settings'),
|
||||||
$action_name === 'facebooksettings');
|
$action_name === 'facebooksettings'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -325,19 +322,75 @@ ENDOFSCRIPT;
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Log the user out of Facebook, per the Facebook authentication guide
|
||||||
|
*
|
||||||
|
* @param Action action the action
|
||||||
|
*/
|
||||||
|
function onEndLogout($action)
|
||||||
|
{
|
||||||
|
$session = $this->facebook->getSession();
|
||||||
|
$fbuser = null;
|
||||||
|
$fbuid = null;
|
||||||
|
|
||||||
|
if ($session) {
|
||||||
|
try {
|
||||||
|
$fbuid = $this->facebook->getUser();
|
||||||
|
$fbuser = $this->facebook->api('/me');
|
||||||
|
} catch (FacebookApiException $e) {
|
||||||
|
common_log(LOG_ERROR, $e, __FILE__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($fbuser)) {
|
||||||
|
|
||||||
|
$logoutUrl = $this->facebook->getLogoutUrl(
|
||||||
|
array('next' => common_local_url('public'))
|
||||||
|
);
|
||||||
|
|
||||||
|
common_log(
|
||||||
|
LOG_INFO,
|
||||||
|
sprintf(
|
||||||
|
"Logging user out of Facebook (fbuid = %s)",
|
||||||
|
$fbuid
|
||||||
|
),
|
||||||
|
__FILE__
|
||||||
|
);
|
||||||
|
|
||||||
|
common_redirect($logoutUrl, 303);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add fbml namespace so Facebook's JavaScript SDK can parse and render
|
||||||
|
* XFBML tags (e.g: <fb:login-button>)
|
||||||
|
*
|
||||||
|
* @param Action $action current action
|
||||||
|
* @param array $attrs array of attributes for the HTML tag
|
||||||
|
*
|
||||||
|
* @return nothing
|
||||||
|
*/
|
||||||
function onStartHtmlElement($action, $attrs) {
|
function onStartHtmlElement($action, $attrs) {
|
||||||
$attrs = array_merge($attrs, array('xmlns:fb' => 'http://www.facebook.com/2008/fbml'));
|
$attrs = array_merge($attrs, array('xmlns:fb' => 'http://www.facebook.com/2008/fbml'));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add version info for this plugin
|
||||||
|
*
|
||||||
|
* @param array &$versions plugin version descriptions
|
||||||
|
*/
|
||||||
function onPluginVersion(&$versions)
|
function onPluginVersion(&$versions)
|
||||||
{
|
{
|
||||||
$versions[] = array('name' => 'Facebook Single-Sign-On',
|
$versions[] = array(
|
||||||
|
'name' => 'Facebook Single-Sign-On',
|
||||||
'version' => STATUSNET_VERSION,
|
'version' => STATUSNET_VERSION,
|
||||||
'author' => 'Zach Copley',
|
'author' => 'Zach Copley',
|
||||||
'homepage' => 'http://status.net/wiki/Plugin:FacebookSSO',
|
'homepage' => 'http://status.net/wiki/Plugin:FacebookSSO',
|
||||||
'rawdescription' =>
|
'rawdescription' =>
|
||||||
_m('A plugin for single-sign-on with Facebook.'));
|
_m('A plugin for single-sign-on with Facebook.')
|
||||||
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* @category Pugin
|
* @category Plugin
|
||||||
* @package StatusNet
|
* @package StatusNet
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @copyright 2010 StatusNet, Inc.
|
* @copyright 2010 StatusNet, Inc.
|
||||||
@ -34,6 +34,7 @@ if (!defined('STATUSNET')) {
|
|||||||
|
|
||||||
class FacebookloginAction extends Action
|
class FacebookloginAction extends Action
|
||||||
{
|
{
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
@ -53,7 +54,7 @@ class FacebookloginAction extends Action
|
|||||||
);
|
);
|
||||||
|
|
||||||
$session = $facebook->getSession();
|
$session = $facebook->getSession();
|
||||||
$me = null;
|
$fbuser = null;
|
||||||
|
|
||||||
if ($session) {
|
if ($session) {
|
||||||
try {
|
try {
|
||||||
@ -86,10 +87,11 @@ class FacebookloginAction extends Action
|
|||||||
|
|
||||||
if (!empty($user)) {
|
if (!empty($user)) {
|
||||||
|
|
||||||
common_debug(
|
common_log(
|
||||||
|
LOG_INFO,
|
||||||
sprintf(
|
sprintf(
|
||||||
'Logged in Facebook user $s as user %d (%s)',
|
'Logged in Facebook user %s as user %s (%s)',
|
||||||
$this->fbuid,
|
$fbuid,
|
||||||
$user->id,
|
$user->id,
|
||||||
$user->nickname
|
$user->nickname
|
||||||
),
|
),
|
||||||
@ -150,9 +152,9 @@ class FacebookloginAction extends Action
|
|||||||
$this->elementStart('fieldset');
|
$this->elementStart('fieldset');
|
||||||
|
|
||||||
$attrs = array(
|
$attrs = array(
|
||||||
'show-faces' => 'true',
|
//'show-faces' => 'true',
|
||||||
'width' => '100',
|
//'max-rows' => '4',
|
||||||
'max-rows' => '2',
|
//'width' => '600',
|
||||||
'perms' => 'user_location,user_website,offline_access,publish_stream'
|
'perms' => 'user_location,user_website,offline_access,publish_stream'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user