Skip to content

Instantly share code, notes, and snippets.

@patbenatar
Created May 17, 2012 17:56
Show Gist options
  • Save patbenatar/2720548 to your computer and use it in GitHub Desktop.
Save patbenatar/2720548 to your computer and use it in GitHub Desktop.
CoffeeScript to authorize FB connect with FB JS SDK and omniauth
authorizePlayer = ->
FBLoad =>
FB.getLoginStatus (response) ->
if response.status == 'connected'
# the user is logged in and connected to app
window.location.href = '/players/auth/facebook/callback'
else if response.status == "not_authorized"
# the user is logged in to Facebook, but not connected to app
# Attempt to auth
FB.login (response) ->
if response.authResponse
# User accepted auth
window.location.href = '/players/auth/facebook/callback'
else
# User cancelled login or did not fully authorize.
, scope: 'offline_access'
else
# User not logged into Facebook. Do something here.
return false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment