Skip to content

Instantly share code, notes, and snippets.

@joshsmith
Created December 1, 2011 00:05
Show Gist options
  • Save joshsmith/1412096 to your computer and use it in GitHub Desktop.
Save joshsmith/1412096 to your computer and use it in GitHub Desktop.
everyauth.facebook
.entryPath('/auth/facebook')
.scope('email, user_likes, user_location, offline_access, publish_stream, publish_checkins, publish_actions')
.appId(app.settings.fbAppId)
.appSecret(app.settings.fbAppSecret)
.findOrCreateUser(function(session, accessToken, accessTokExtra, fbUserMetadata) {
User.findOne().where('facebook.id', fbUserMetadata.id).run(function(err, user) {
console.log(user);
if(user) {
// Update
} else {
var user = new User({
name: response.name,
first_name: response.first_name,
last_name: response.last_name,
facebook: {
id: response.id,
accessToken: facebookRes.access_token
},
location: response.location.name,
gender: response.gender,
email: response.email
});
}
user.save(function(err) {
console.log('hello');
if(err) {
promise.fail(err);
} else {
promise.fulfill(user);
}
});
})
})
.redirectPath('/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment