Skip to content

Instantly share code, notes, and snippets.

@ashaw
Created May 11, 2011 14:52
Show Gist options
  • Save ashaw/966591 to your computer and use it in GitHub Desktop.
Save ashaw/966591 to your computer and use it in GitHub Desktop.
var jankyLoginStatus = function(cb) {
var that = this;
var statusObj = {};
// see if we can get "me"
FB.api('/me', function(response) {
// we can't get me. Verify it's an OAuthException, and then sub in notConnected.
if (response['error'] && response['error']['type'] === "OAuthException") {
statusObj['status'] = "notConnected";
FB.logout(); // just to make sure we don't have stale cookies
return cb(statusObj);
} else {
// they have a session and are connected.
// stash a copy of "me"
that.me = response;
// stash the session so we can store tokens, etc.
statusObj['status'] = "connected"
statusObj['session'] = FB.getSession();
return cb(statusObj);
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment