Skip to content

Instantly share code, notes, and snippets.

@georgi
Created January 17, 2012 23:41
Show Gist options
  • Save georgi/1629802 to your computer and use it in GitHub Desktop.
Save georgi/1629802 to your computer and use it in GitHub Desktop.
getLoginStatus
function (a, b) {
if (!FB._apiKey) {
FB.log('FB.getLoginStatus() called before calling FB.init().');
return;
}
if (a) if (!b && FB.Auth._loadState == 'loaded') {
if (FB._oauth) {
a({
status: FB._userStatus,
authResponse: FB._authResponse
});
} else a({
status: FB._userStatus,
session: FB._session
});
return;
} else FB.Event.subscribe('FB.loginStatus', a);
if (!b && FB.Auth._loadState == 'loading') return;
FB.Auth._loadState = 'loading';
var c = function (d) {
FB.Auth._loadState = 'loaded';
FB.Event.fire('FB.loginStatus', d);
FB.Event.clear('FB.loginStatus');
};
if (FB.UA.mobile() && window.postMessage && window.localStorage) {
FB.Auth.staticAuthCheck(c);
} else if (FB._oauth) {
FB.ui({
method: 'login.status',
display: 'none',
domain: location.hostname
}, c);
} else FB.ui({
method: 'auth.status',
display: 'hidden'
}, c);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment