Sup_File/auth/facebook.js
2018-05-31 00:37:35 +02:00

37 lines
1.3 KiB
JavaScript

var passport = require('passport');
var FacebookStrategy = require('passport-facebook').Strategy;
var User = require('../models/user');
// module.exports = function(passport){
//
// };
passport.use(new FacebookStrategy({
clientID: "191092458179642",
clientSecret: "964e490d7e49a13ee7a77c9b65419fb3",
callbackURL: "http://127.0.0.1:3000/api/facebook/callback"
},
function(accessToken, refreshToken, profile, done) {
console.log('yaaauuu : ' + accessToken + ' ----- ' + profile.displayName + ' ----- ' + profile.id);
done(null, {profile, accessToken});
// User.findOrCreate({username: profile.displayName}, {username: profile.displayName, id: profile.id}, function(err, user) {
// if (err) {
// console.log('yaaauuu err : ' + err);
// return done(err);
// }
// console.log('yaaauuu : ');
// done(null, user);
// });
/*
User.findOrCreate({username: profile.displayName}, {username: profile.displayName, id: profile.id}, function(err, user) {
console.log('yaaauuu err : ' + ' ----- ' + err );
console.log('yaaauuu user : ' + ' ----- ' + JSON.stringify(user));
if (err) { return done(err); }
done(null, user);
});*/
}
));
module.exports = passport;