From 3b002a6fb136b9e7e534ffbcfedabed72fcd373d Mon Sep 17 00:00:00 2001 From: nanalelfe Date: Tue, 26 Jul 2016 21:45:42 -0400 Subject: Added passport-facbeook --- config/auth.js | 7 +++++++ config/passport.js | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 config/auth.js (limited to 'config') diff --git a/config/auth.js b/config/auth.js new file mode 100644 index 0000000..c46c55e --- /dev/null +++ b/config/auth.js @@ -0,0 +1,7 @@ +module.exports = { + 'facebookAuth' : { + 'clientID' : '1618318315164670', + 'clientSecret' : 'b4b67801b2b37f795871ce7cc55a33cf', + 'callbackURL' : 'http://localhost:3000/auth/facebook/callback' + } +} \ No newline at end of file diff --git a/config/passport.js b/config/passport.js index 38e9397..be8cf10 100644 --- a/config/passport.js +++ b/config/passport.js @@ -1,8 +1,11 @@ var passport = require('passport'); var dbFile = require("../node_simple.js"); var LocalStrategy = require('passport-local').Strategy; +var FacebookStrategy = require('passport-facebook').Strategy; var bcrypt = require('bcrypt-nodejs'); +var configAuth = require('./auth'); + var exports = module.exports = {}; var encryptPassword = exports.encryptPassword = function (password) { @@ -138,3 +141,16 @@ passport.use('local_signin', new LocalStrategy({ } }); })); + +passport.use(new FacebookStrategy({ + clientID: configAuth.facebookAuth.clientID, + clientSecret: configAuth.facebookAuth.clientSecret, + callbackURL: configAuth.facebookAuth.callbackURL + }, + function(accessToken, refreshToken, profile, done) { + User.findOrCreate(..., function(err, user) { + if (err) { return done(err); } + done(null, user); + }); + } +)); \ No newline at end of file -- cgit v1.2.3