- More, more, more...

This commit is contained in:
2019-07-04 23:06:04 -04:00
parent 6d5d238d34
commit af13551042
16 changed files with 348 additions and 94 deletions

View File

@@ -5,11 +5,12 @@ const config = require('../../config');
const User = require('../../models/user');
module.exports = function(passport) {
passport.use(new FacebookStrategy(
passport.use('facebook', new FacebookStrategy(
{
clientID: config.services.facebook.appId,
clientSecret: config.services.facebook.appSecret,
callbackURL: 'http://localhost:3001/auth/facebook/callback',
callbackURL: 'http://localhost:3001/auth/facebook/loggedin',
profileFields: ['id', 'email', 'first_name', 'last_name', 'picture'],
},
(accessToken, refreshToken, profile, done) => {
@@ -28,6 +29,7 @@ module.exports = function(passport) {
},
{
accessToken,
associatedEmail: email,
method: profile.provider,
userId,
},
@@ -43,4 +45,32 @@ module.exports = function(passport) {
);
}
));
passport.use('facebookLink', new FacebookStrategy(
{
clientID: config.services.facebook.appId,
clientSecret: config.services.facebook.appSecret,
callbackURL: 'http://localhost:3001/auth/facebook/linked',
profileFields: ['id', 'email', 'first_name', 'last_name', 'picture'],
},
(accessToken, refreshToken, profile, done) => {
const {
email,
first_name: firstName,
id: userId,
last_name: lastName,
picture: { data: { url = null } = {} } = {},
} = profile._json;
const avatar = url;
const strategy = {
accessToken,
associatedEmail: email,
method: profile.provider,
userId,
};
return done(null, { avatar, strategy });
}
));
};

View File

@@ -74,6 +74,7 @@ module.exports = function (passport) {
return {
basic: authenticateBasic(passport),
bypass: (req, res, next) => next(),
manager: authenticateEventManager(passport),
managerOrSelf: authenticateEventManagerOrSelf(passport),
passport,