Skip to content

Instantly share code, notes, and snippets.

@StabbyMcDuck
Last active November 20, 2016 14:25
Show Gist options
  • Save StabbyMcDuck/1f8be22e1398f0c54b54c689b5698682 to your computer and use it in GitHub Desktop.
Save StabbyMcDuck/1f8be22e1398f0c54b54c689b5698682 to your computer and use it in GitHub Desktop.
jQuery ->
$('body').prepend('<div id="fb-root"></div>')
$.ajax
url: "#{window.location.protocol}//connect.facebook.net/en_US/all.js"
dataType: 'script'
cache: true
window.fbAsyncInit = ->
FB.init(appId: 'YOUR_FACEBOOK_APP_ID', cookie: true)
$('#facebook_sign_in').click (e) ->
e.preventDefault()
FB.login (response) ->
console.log('FB.login called')
window.location = '/auth/facebook/callback' if response.authResponse
$('#sign_out').click (e) ->
FB.getLoginStatus (response) ->
FB.logout() if response.authResponse
true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment