Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
require("../model/user").findOne({token : token}, function(err, user) {
if(err) {
return done(err);
}
if(user) {
return done(null, user);
} else {
return done(null, false, {message : "invalid_token"});
}
});
})
);
passport.use(
new FBTokenStrategy({
clientID : app_config.FB_CLIENT_ID
, clientSecret : app_config.FB_CLIENT_SECRET
}
, function(accessToken, refreshToken, profile, done) {
var User = require("../model/user");
//console.log(profile);
User.findOne({"facebook.id" : profile.id}, function(err, user) {
if(err) {
return done(err);
}
if(user) {
user.token = accessToken;
} else {
firstName: profile._json.first_name,
lastName: profile._json.last_name,
email: profile._json.email
};
User.create(user, function(err, user){
if(err){ return done(err, null); }
return done(err, user);
});
}
});
});
}));
passport.use(new FacebookTokenStrategy({
clientID: config.passport.facebook.clientID,
clientSecret: config.passport.facebook.clientSecret
},
function(accessToken, refreshToken, profile, done) {
User.findOrCreate({ facebookId: profile.id }, function (err, user) {
return done(err, user);
});
}));
}
code: 'E_AUTH_FAILED',
message: [profile.provider, ' auth failed'].join('')
});
return next(null, user, {});
})
.catch(next);
} else {
req.user.socialProfiles[profile.provider] = profile._json;
req.user.save(next);
}
}
passport.use(new LocalStrategy(_.assign({}, LOCAL_STRATEGY_CONFIG), _onLocalStrategyAuth));
passport.use(new JwtStrategy(_.assign({}, JWT_STRATEGY_CONFIG), _onJwtStrategyAuth));
passport.use(new FacebookTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new TwitterTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new VKontakteTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new FoursquareTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new GitHubTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new InstagramTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new PayPalTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new RedditTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new SoundCloudTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new WindowsLiveTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new TwitchTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new YandexTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new AmazonTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new GooglePlusTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new YahooTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
module.exports = function(passport) {
passport.serializeUser(serialize);
passport.deserializeUser(deserialize);
passport.use(new FacebookTokenStrategy({
clientID: 'facebook_id',
clientSecret: 'facebook_secrect_key',
redirectURL: 'facebook_redirect_url'
}, facebookAuth));
};