Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*
* As you can see, this function handles both "authentication" and "authori-
* zation" at the same time. This is due to the fact that we pass in
* `passReqToCallback: true` when loading the strategies, allowing us to look
* for an existing session in the request and taking action based on that.
*
* For more information on auth(entication|rization) in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
* http://passportjs.org/guide/authorize/
*
* @param {Request} request
* @param {*} query
* @param {{}} profile
* @param {Function} next
*/
passport.connect = function connect(request, query, profile, next) {
sails.log.verbose(__filename + ':' + __line + ' [Service.Passport.connect() called]');
var user = {};
// Set the authentication provider.
query.provider = request.param('provider');
// If the profile object contains a list of emails, grab the first one and add it to the user.
if (profile.hasOwnProperty('emails')) {
user.email = profile.emails[0].value;
}
// If the profile object contains a username, add it to the user.
if (profile.hasOwnProperty('username')) {
user.username = profile.username;
}
*
* As you can see, this function handles both "authentication" and "authori-
* zation" at the same time. This is due to the fact that we pass in
* `passReqToCallback: true` when loading the strategies, allowing us to look
* for an existing session in the request and taking action based on that.
*
* For more information on auth(entication|rization) in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
* http://passportjs.org/guide/authorize/
*
* @param {Object} req
* @param {Object} query
* @param {Object} profile
* @param {Function} next
*/
passport.connect = function (req, query, profile, next) {
var user = {}
, provider;
// Get the authentication provider from the query.
query.provider = req.param('provider');
// Use profile.provider or fallback to the query.provider if it is undefined
// as is the case for OpenID, for example
provider = profile.provider || query.provider;
// If the provider cannot be identified we cannot match it to a passport so
// throw an error and let whoever's next in line take care of it.
if (!provider){
return next(new Error('No authentication provider was identified.'));
}
*
* As you can see, this function handles both "authentication" and "authori-
* zation" at the same time. This is due to the fact that we pass in
* `passReqToCallback: true` when loading the strategies, allowing us to look
* for an existing session in the request and taking action based on that.
*
* For more information on auth(entication|rization) in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
* http://passportjs.org/guide/authorize/
*
* @param {Object} req
* @param {Object} query
* @param {Object} profile
* @param {Function} next
*/
passport.connect = function (req, query, profile, next) {
var user = {};
// Use profile.provider or fallback to the query.provider if it is undefined
// as is the case for OpenID, for example
var provider = profile.provider || req.param('provider');
req.session.tokens = query.tokens;
// Get the authentication provider from the query.
query.provider = provider;
// If the provider cannot be identified we cannot match it to a passport so
// throw an error and let whoever's next in line take care of it.
if (!provider) {
return next(new Error('No authentication provider was identified.'));
}
*
* As you can see, this function handles both "authentication" and "authori-
* zation" at the same time. This is due to the fact that we pass in
* `passReqToCallback: true` when loading the strategies, allowing us to look
* for an existing session in the request and taking action based on that.
*
* For more information on auth(entication|rization) in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
* http://passportjs.org/guide/authorize/
*
* @param {Object} req
* @param {Object} query
* @param {Object} profile
* @param {Function} next
*/
passport.connect = function (req, query, profile, next) {
var strategies = sails.config.passport
, config = strategies[profile.provider]
, user = {};
// Set the authentication provider.
query.provider = req.param('provider');
// If the profile object contains a list of emails, grab the first one and
// add it to the user.
if (profile.hasOwnProperty('emails')) {
user.email = profile.emails[0].value;
}
// If the profile object contains a username, add it to the user.
if (profile.hasOwnProperty('username')) {
user.username = profile.username;
*
* As you can see, this function handles both "authentication" and "authori-
* zation" at the same time. This is due to the fact that we pass in
* `passReqToCallback: true` when loading the strategies, allowing us to look
* for an existing session in the request and taking action based on that.
*
* For more information on auth(entication|rization) in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
* http://passportjs.org/guide/authorize/
*
* @param {Object} request
* @param {Object} query
* @param {Object} profile
* @param {Function} next
*/
passport.connect = function(request, query, profile, next) {
var strategies = sails.config.passport;
var config = strategies[profile.provider];
var user = {};
// Set the authentication provider.
query.provider = request.param('provider');
// If the profile object contains a list of emails, grab the first one and add it to the user.
if (profile.hasOwnProperty('emails')) {
user.email = profile.emails[0].value;
}
// If the profile object contains a username, add it to the user.
if (profile.hasOwnProperty('username')) {
user.username = profile.username;
}
*
* As you can see, this function handles both "authentication" and "authori-
* zation" at the same time. This is due to the fact that we pass in
* `passReqToCallback: true` when loading the strategies, allowing us to look
* for an existing session in the request and taking action based on that.
*
* For more information on auth(entication|rization) in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
* http://passportjs.org/guide/authorize/
*
* @param {Object} req
* @param {Object} query
* @param {Object} profile
* @param {Function} next
*/
passport.connect = function (req, query, profile, next) {
const user = {};
// Get the authentication provider from the query.
query.provider = req.param('provider');
// Use profile.provider or fallback to the query.provider if it is undefined
// as is the case for OpenID, for example
const provider = profile.provider || query.provider;
// If the provider cannot be identified we cannot match it to a passport so
// throw an error and let whoever's next in line take care of it.
if (!provider){
return next(new Error('No authentication provider was identified.'));
}
// If the profile object contains a list of emails, grab the first one and
*
* As you can see, this function handles both "authentication" and "authori-
* zation" at the same time. This is due to the fact that we pass in
* `passReqToCallback: true` when loading the strategies, allowing us to look
* for an existing session in the request and taking action based on that.
*
* For more information on auth(entication|rization) in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
* http://passportjs.org/guide/authorize/
*
* @param {Object} req
* @param {Object} query
* @param {Object} profile
* @param {Function} next
*/
passport.connect = function (req, query, profile, next) {
var user = {}
, provider;
// Get the authentication provider from the query.
query.provider = req.param('provider');
// Use profile.provider or fallback to the query.provider if it is undefined
// as is the case for OpenID, for example
provider = profile.provider || query.provider;
// If the provider cannot be identified we cannot match it to a passport so
// throw an error and let whoever's next in line take care of it.
if (!provider){
return next(new Error('No authentication provider was identified.'));
}
*
* As you can see, this function handles both "authentication" and "authori-
* zation" at the same time. This is due to the fact that we pass in
* `passReqToCallback: true` when loading the strategies, allowing us to look
* for an existing session in the request and taking action based on that.
*
* For more information on auth(entication|rization) in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
* http://passportjs.org/guide/authorize/
*
* @param {Object} req
* @param {Object} query
* @param {Object} profile
* @param {Function} next
*/
passport.connect = function (req, query, profile, next) {
var user = {}
, provider;
// Get the authentication provider from the query.
query.provider = req.param('provider');
// Use profile.provider or fallback to the query.provider if it is undefined
// as is the case for OpenID, for example
provider = profile.provider || query.provider;
// If the provider cannot be identified we cannot match it to a passport so
// throw an error and let whoever's next in line take care of it.
if (!provider){
return next(new Error('No authentication provider was identified.'));
}
*
* As you can see, this function handles both "authentication" and "authori-
* zation" at the same time. This is due to the fact that we pass in
* `passReqToCallback: true` when loading the strategies, allowing us to look
* for an existing session in the request and taking action based on that.
*
* For more information on auth(entication|rization) in Passport.js, check out:
* http://passportjs.org/guide/authenticate/
* http://passportjs.org/guide/authorize/
*
* @param {Object} req
* @param {Object} query
* @param {Object} profile
* @param {Function} next
*/
passport.connect = function (req, query, profile, next) {
var user = {}
, provider;
// Get the authentication provider from the query.
query.provider = req.param('provider');
// Use profile.provider or fallback to the query.provider if it is undefined
// as is the case for OpenID, for example
provider = profile.provider || query.provider;
// If the provider cannot be identified we cannot match it to a passport so
// throw an error and let whoever's next in line take care of it.
if (!provider){
return next(new Error('No authentication provider was identified.'));
}