Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}, function(accessToken, refreshToken, profile, done) {
console.log('Received Facebook profile from: ', profile.displayName);
return done(null, profile);
});
passport.use(strategy);
passport.serializeUser(function(user, done) {
done(null, user);
});
passport.deserializeUser(function(user, done) {
done(null, user);
});
passport.callback = function(req, res, next) {
passport.authenticate('auth0', function(err, user) {
if (err) {
console.log(clc.red('Error: Auth0 ' + err));
return next(err); // will generate a 500 error
} else if (!user) {
console.log('Unknown user logging with FB');
return res.redirect('/admin?error=1');
}
return res.redirect('/admin?user=' + user.displayName);
})(req, res, next);
}
module.exports = passport;
// /auth/:provider/callback
this.authenticate(provider, options)(request, response, request.next);
}
};
/**
* Create an authentication callback endpoint
*
* For more information on authentication in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
*
* @param {Request} request
* @param {Response} response
* @param {Function} next
*/
passport.callback = function callback(request, response, next) {
sails.log.verbose(__filename + ':' + __line + ' [Service.Passport.callback() called]');
var provider = request.param('provider', 'local');
var action = request.param('action');
if (provider === 'local' && action !== undefined) {
if (action === 'connect' && request.user) {
this.protocols.local.connect(request, response, next);
} else {
next(new Error('Invalid action'));
}
} else {
// Load authentication strategies
this.loadStrategies(request);
// The provider will redirect the user to this URL after approval. Finish
// the provider will redirect the user back to the application at
// /auth/:provider/callback
this.authenticate(provider, options)(req, res, req.next);
};
/**
* Create an authentication callback endpoint
*
* For more information on authentication in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
*
* @param {Object} req
* @param {Object} res
* @param {Function} next
*/
passport.callback = function (req, res, next) {
var provider = req.param('provider', 'local')
, action = req.param('action');
// Passport.js wasn't really built for local user registration, but it's nice
// having it tied into everything else.
if (provider === 'local' && action !== undefined) {
if (action === 'register' && !req.user) {
this.protocols.local.register(req, res, next);
}
else if (action === 'connect' && req.user) {
this.protocols.local.connect(req, res, next);
}
else if (action === 'disconnect' && req.user) {
this.disconnect(req, res, next);
}
else {
// the provider will redirect the user back to the application at
// /auth/:provider/callback
this.authenticate(provider, options)(req, res, req.next);
};
/**
* Create an authentication callback endpoint
*
* For more information on authentication in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
*
* @param {Object} req
* @param {Object} res
* @param {Function} next
*/
passport.callback = function (req, res, next) {
var provider = req.param('provider', 'local')
, action = req.param('action');
// Passport.js wasn't really built for local user registration, but it's nice
// having it tied into everything else.
if (provider === 'local' && action !== undefined) {
if (action === 'register' && !req.user) {
this.protocols.local.register(req, res, next);
}
else if (action === 'connect' && req.user) {
this.protocols.local.connect(req, res, next);
}
else if (action === 'disconnect' && req.user) {
this.protocols.local.disconnect(req, res, next);
}
else {
// the provider will redirect the user back to the application at
// /auth/:provider/callback
this.authenticate(provider, options)(req, res, req.next);
};
/**
* Create an authentication callback endpoint
*
* For more information on authentication in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
*
* @param {Object} req
* @param {Object} res
* @param {Function} next
*/
passport.callback = function (req, res, next) {
var provider = req.param('provider', 'local');
var action = req.param('action');
// Passport.js wasn't really built for local user registration, but it's nice
// having it tied into everything else.
if (provider === 'local' && action !== undefined) {
if (action === 'register' && !req.user) {
this.protocols.local.register(req, res, next);
} else if (action === 'connect' && req.user) {
this.protocols.local.connect(req, res, next);
} else if (action === 'disconnect' && req.user) {
this.protocols.local.disconnect(req, res, next);
} else {
next(new Error('Invalid action'));
}
} else {
// the provider will redirect the user back to the application at
// /auth/:provider/callback
this.authenticate(provider, options)(req, res, req.next);
};
/**
* Create an authentication callback endpoint
*
* For more information on authentication in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
*
* @param {Object} req
* @param {Object} res
* @param {Function} next
*/
passport.callback = function (req, res, next) {
var provider = req.param('provider', 'local')
, action = req.param('action');
// Passport.js wasn't really built for local user registration, but it's nice
// having it tied into everything else.
if (provider === 'local' && action !== undefined) {
if (action === 'register' && !req.user) {
this.protocols.local.register(req, res, next);
}
else if (action === 'connect' && req.user) {
this.protocols.local.connect(req, res, next);
}
else if (action === 'disconnect' && req.user) {
this.disconnect(req, res, next);
}
else {
// /auth/:provider/callback
this.authenticate(provider, options)(request, response, request.next);
}
};
/**
* Create an authentication callback endpoint
*
* For more information on authentication in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
*
* @param {Object} request
* @param {Object} response
* @param {Function} next
*/
passport.callback = function(request, response, next) {
var provider = request.param('provider', 'local');
var action = request.param('action');
if (provider === 'local' && action !== undefined) {
if (action === 'connect' && request.user) {
this.protocols.local.connect(request, response, next);
} else {
next(new Error('Invalid action'));
}
} else {
// Load authentication strategies
this.loadStrategies(request);
// The provider will redirect the user to this URL after approval. Finish
// the authentication process by attempting to obtain an access token. If
// access was granted, the user will be logged in. Otherwise, authentication
// the provider will redirect the user back to the application at
// /auth/:provider/callback
this.authenticate(provider, options)(req, res, req.next);
};
/**
* Create an authentication callback endpoint
*
* For more information on authentication in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
*
* @param {Object} req
* @param {Object} res
* @param {Function} next
*/
passport.callback = function (req, res, next) {
var provider = req.param('provider', 'local')
, action = req.param('action');
// Passport.js wasn't really built for local user registration, but it's nice
// having it tied into everything else.
if (provider === 'local' && action !== undefined) {
if (action === 'register' && !req.user) {
this.protocols.local.register(req, res, next);
}
else if (action === 'connect' && req.user) {
this.protocols.local.connect(req, res, next);
}
else {
next(new Error('Invalid action'));
}
} else {
// the provider will redirect the user back to the application at
// /auth/:provider/callback
this.authenticate(provider, options)(req, res, req.next);
};
/**
* Create an authentication callback endpoint
*
* For more information on authentication in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
*
* @param {Object} req
* @param {Object} res
* @param {Function} next
*/
passport.callback = function (req, res, next) {
var provider = req.param('provider', 'local')
, action = req.param('action');
// Passport.js wasn't really built for local user registration, but it's nice
// having it tied into everything else.
if (provider === 'local' && action !== undefined) {
if (action === 'register' && !req.user) {
this.protocols.local.register(req, res, next);
}
else if (action === 'connect' && req.user) {
this.protocols.local.connect(req, res, next);
}
else if (action === 'disconnect' && req.user) {
this.protocols.local.disconnect(req, res, next);
}
else {
// the provider will redirect the user back to the application at
// /auth/:provider/callback
this.authenticate(provider, options)(req, res, req.next);
};
/**
* Create an authentication callback endpoint
*
* For more information on authentication in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
*
* @param {Object} req
* @param {Object} res
* @param {Function} next
*/
passport.callback = function (req, res, next) {
const provider = req.param('provider', 'local'),
action = req.param('action');
// Passport.js wasn't really built for local user registration, but it's nice
// having it tied into everything else.
if (provider === 'local' && action !== undefined) {
if (action === 'register' && !req.user) {
this.protocols.local.register(req, res, next);
} else if (action === 'connect' && req.user) {
this.protocols.local.connect(req, res, next);
} else if (action === 'disconnect' && req.user) {
this.disconnect(req, res, next);
} else {
next(new Error('Invalid action'));
}
} else {