Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Tenzing
/
Tz Tools
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
3b272b09
authored
2010-07-07 21:12:47 +0000
by
Chris Boden
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Logout of Facebook by URL redirects (PHP SDK) instead of JavaScript, removed jun…
…k code, added comments
1 parent
5d852d0a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
20 deletions
com/Auth/Facebook/Facebook.php
com/Auth/Facebook/Facebook.php
View file @
3b272b0
...
...
@@ -42,7 +42,7 @@ const OPTION_NAME = 'tz_auth_fb';
function
drawLoginButton
(
$echo
=
true
)
{
$title
=
Vars
::
$options
[
'button_title'
]
?:
'Login'
;
$btn
=
'<a id="TzFB" class="fb_button fb_button_medium"><span class="fb_button_text">'
.
$title
.
'</span></a>'
;
//
$btn = '<fb:login-button></fb:login-button>';
//
$btn = '<fb:login-button></fb:login-button>';
if
(
!
$echo
)
{
return
$btn
;
...
...
@@ -68,28 +68,12 @@ function getSDK() {
}
function
load
()
{
Vars
::
$loaded
=
true
;
?>
<div
id=
"fb-root"
></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: '
<?php
echo
Vars
::
$options
[
'application_id'
];
?>
', status: true, cookie: true, xfbml: true});
FB.Event.subscribe('
auth
.
login
', function(response) { window.location.reload(); });
<?php
if
(
isset
(
$_COOKIE
[
'wpfb_logout'
]))
:
?>
FB.getLoginStatus(function(response) {
if (response.session) {
FB.logout(function() {
var date = new Date();
date.setTime(date.getTime() - 1);
document.cookie = 'wpfb_logout=;expires=' + date.toGMTString() + ';path=/';
// window.location.reload();
});
}
});
<?php
endif
;
?>
};
(function() {
...
...
@@ -105,13 +89,19 @@ function load() {
class
Actions
{
public
static
function
set_current_user
()
{
$sdk
=
getSDK
();
// User is not logged in to Facebook
if
(
null
===
(
$sess
=
$sdk
->
getSession
()))
{
return
;
}
// User logged out of WordPress, log them out of Facebook
if
(
isset
(
$_COOKIE
[
'wpfb_logout'
]))
{
setcookie
(
'wpfb_logout'
,
''
,
time
()
-
3600
,
'/'
,
Vars
::
$options
[
'domain_name'
]);
$url
=
$sdk
->
getLogoutUrl
();
$sdk
->
setSession
();
return
;
header
(
'Location: '
.
$url
);
}
// if user is not logged in do the following
...
...
@@ -135,6 +125,9 @@ class Actions {
if
(
username_exists
(
$username
))
{
$user
=
Auth\signin
(
$username
);
}
else
{
// User logged in via Facebook for the first time, register/activate a linked WordPress account
// Email address is already registered...
if
(
false
!==
get_user_by
(
'email'
,
$info
[
'email'
]))
{
// Not sure if I can throw exception, this is outside the theme stuff...
throw
new
Exception
(
'email conflict'
);
...
...
@@ -169,7 +162,7 @@ class Actions {
}
/**
*
Destroy Facebook session data on site if the log out of WordPre
ss
*
Set a cookie to tell this to logout of Facebook on next pa
ss
*/
public
static
function
wp_logout
()
{
setcookie
(
'wpfb_logout'
,
1
,
0
,
'/'
,
Vars
::
$options
[
'domain_name'
]);
...
...
@@ -200,6 +193,5 @@ class Vars {
* @type WP_Option
*/
public
static
$options
;
public
static
$loaded
=
false
;
}
?>
\ No newline at end of file
...
...
Please
register
or
sign in
to post a comment