Skip to content

Instantly share code, notes, and snippets.

@dodops
Created July 23, 2015 21:41
Show Gist options
  • Save dodops/79c685c21e5b11b449a2 to your computer and use it in GitHub Desktop.
Save dodops/79c685c21e5b11b449a2 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/sdk.js"
dataType: 'script'
cache: true
window.fbAsyncInit = ->
FB.init
appId: 'app-id'
cookie: true
version: 'v2.2'
$('#sign_in').click (e) ->
e.preventDefault()
FB.login (response) ->
window.location = '/users/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