Skip to content
This repository has been archived by the owner on Aug 4, 2019. It is now read-only.

Commit

Permalink
Fix Facebook registration bug
Browse files Browse the repository at this point in the history
Facebook switched to OAuth 2.0 in Decemeber which broke registration. Fixed.
  • Loading branch information
feross committed Jun 20, 2012
1 parent a2971e8 commit 51b2a77
Showing 1 changed file with 37 additions and 35 deletions.
72 changes: 37 additions & 35 deletions static/js/setup.js
Expand Up @@ -196,23 +196,24 @@ function setupKeyboardShortcuts() {
}

function setupFBML() {
window.fbAsyncInit = function() {
FB.init({
appId: appSettings.fbAppId,
status: true,
cookie: true,
xfbml: true
});
};

(function() {
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js#appId='+appSettings.fbAppId+'&xfbml=1';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
window.fbAsyncInit = function() {
FB.init({
appId : appSettings.fbAppId, // App ID
channelUrl : '//'+window.location.host+'/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};

// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
}

function setupUploader(formElem) {
Expand Down Expand Up @@ -438,22 +439,23 @@ function setupSignup() {
var form = $('#fbSignupForm');

// Facepile
FB.XFBML.parse($('#fbFacepile').get(0), function(response) {
// If none of the user's friends have connected to Instant.fm,
// then lets fallback to showing the users who have liked our
// page (including non-friends). We show the like box, but
// use CSS trickery to just show the faces.
window.setTimeout(function() {
if ($('#fbFacepile').height() < 20) {
$('#fbFacepile')
.empty()
.addClass('like')
.append('<fb:like-box href="'+appSettings.fbPageURL+'" width="410" show_faces="true" stream="false" header="false"></fb:like-box>');
FB.XFBML.parse($('#fbFacepile').get(0));
}
$.colorbox.resize();
}, 1000);
});
// BUGFIX: I think this causes "Uncaught TypeError: Cannot read property 'offsetWidth' of null"
// FB.XFBML.parse($('#fbFacepile').get(0), function(response) {
// // If none of the user's friends have connected to Instant.fm,
// // then lets fallback to showing the users who have liked our
// // page (including non-friends). We show the like box, but
// // use CSS trickery to just show the faces.
// window.setTimeout(function() {
// if ($('#fbFacepile').height() < 20) {
// $('#fbFacepile')
// .empty()
// .addClass('like')
// .append('<fb:like-box href="'+appSettings.fbPageURL+'" width="410" show_faces="true" stream="false" header="false"></fb:like-box>');
// FB.XFBML.parse($('#fbFacepile').get(0));
// }
// $.colorbox.resize();
// }, 1000);
// });

// Connect button
$('#fbConnectButton').click(onFBConnect);
Expand All @@ -468,15 +470,15 @@ function onFBConnect(event) {
var form = $('#fbSignupForm');

FB.login(function(login_response) {
if (!login_response.session) {
if (!login_response.authResponse) {
log('FB login failed.'); // user cancelled login
return;
}

// Check that they're not already registered
FB.api('/me', function (response) {
var fb_id = response.id,
auth_token = login_response.session.access_token;
auth_token = FB.getAuthResponse()['accessToken'];

instantfm.is_registered_fbid({
params: [fb_id],
Expand Down

0 comments on commit 51b2a77

Please sign in to comment.