How to use the passport.loadStrategies function in passport

To help you get started, we’ve selected a few passport examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kpi-wdc / dj / api / services / passport.js View on Github external
github: {
      name: 'GitHub',
      protocol: 'oauth2',
      strategy: require('passport-github').Strategy
      scope: [ 'user', 'gist' ]
      options: {
        clientID: 'CLIENT_ID',
        clientSecret: 'CLIENT_SECRET'
      }
    }
 *
 * For more information on the providers supported by Passport.js, check out:
 * http://passportjs.org/guide/providers/
 *
 */
passport.loadStrategies = function () {
  var self       = this
    , strategies = sails.config.passport;

  Object.keys(strategies).forEach(function (key) {
    var options = { passReqToCallback: true }, Strategy;

    if (key === 'local') {
      // Since we need to allow users to login using both usernames as well as
      // emails, we'll set the username field to something more generic.
      _.extend(options, { usernameField: 'identifier' });

      // Only load the local strategy if it's enabled in the config
      if (strategies.local) {
        Strategy = strategies[key].strategy;

        self.use(new Strategy(options, self.protocols.local.login));
github ryancp / sailng / api / services / passport.js View on Github external
github: {
      name: 'GitHub',
      protocol: 'oauth2',
      strategy: require('passport-github').Strategy
      scope: [ 'user', 'gist' ]
      options: {
        clientID: 'CLIENT_ID',
        clientSecret: 'CLIENT_SECRET'
      }
    }
 *
 * For more information on the providers supported by Passport.js, check out:
 * http://passportjs.org/guide/providers/
 *
 */
passport.loadStrategies = function () {
  var self       = this
    , strategies = sails.config.passport;

  Object.keys(strategies).forEach(function (key) {
    var options = { passReqToCallback: true }, Strategy;

    if (key === 'local') {
      // Since we need to allow users to login using both usernames as well as
      // emails, we'll set the username field to something more generic.
      _.extend(options, { usernameField: 'identifier' });

      //Let users override the username and passwordField from the options
      _.extend(options, strategies[key].options || {});

      // Only load the local strategy if it's enabled in the config
      if (strategies.local) {
github tarlepp / Taskboard / backend / api / services / Passport.js View on Github external
github: {
      name: 'GitHub',
      protocol: 'oauth2',
      scope: [ 'user', 'gist' ]
      options: {
        clientID: 'CLIENT_ID',
        clientSecret: 'CLIENT_SECRET'
      }
    }
 *
 * For more information on the providers supported by Passport.js, check out:
 * http://passportjs.org/guide/providers/
 *
 * @param   {Object}    request
 */
passport.loadStrategies = function(request) {
    var self = this;
    var strategies = sails.config.passport;

    Object.keys(strategies).forEach(function (key) {
        var options = { passReqToCallback: true }, Strategy;

        if (key === 'local') {
            // Since we need to allow users to login using both usernames as well as
            // emails, we'll set the username field to something more generic.
            _.extend(options, { usernameField: 'identifier' });

            // Only load the local strategy if it's enabled in the config
            if (strategies.local) {
                Strategy = strategies[key].strategy;

                self.use(new Strategy(options, self.protocols.local.login));
github trailsjs / sails-auth / api / services / passport.js View on Github external
*
      github: {
        name: 'GitHub',
        protocol: 'oauth2',
        scope: [ 'user', 'gist' ]
        options: {
          clientID: 'CLIENT_ID',
          clientSecret: 'CLIENT_SECRET'
        }
      }
   *
   * For more information on the providers supported by Passport.js, check out:
   * http://passportjs.org/guide/providers/
   *
   */
  passport.loadStrategies = function () {
    var strategies = sails.config.passport;

    _.each(strategies, _.bind(function (strategy, key) {
      var options = {
        passReqToCallback: true
      };
      var Strategy;

      if (key === 'local') {
        // Since we need to allow users to login using both usernames as well as
        // emails, we'll set the username field to something more generic.
        _.extend(options, {
          usernameField: 'identifier'
        });

        // Only load the local strategy if it's enabled in the config
github sharepointoscar / MEANS / api / services / passport.js View on Github external
github: {
      name: 'GitHub',
      protocol: 'oauth2',
      scope: [ 'user', 'gist' ]
      options: {
        clientID: 'CLIENT_ID',
        clientSecret: 'CLIENT_SECRET'
      }
    }
 *
 * For more information on the providers supported by Passport.js, check out:
 * http://passportjs.org/guide/providers/
 *
 * @param {Object} req
 */
passport.loadStrategies = function (req) {
  var self       = this
    , strategies = sails.config.passport;

  Object.keys(strategies).forEach(function (key) {
    var Strategy = require('passport-' + key).Strategy
      , options  = { passReqToCallback: true };

    if (key === 'local') {
      // Since we need to allow users to login using both usernames as well as
      // emails, we'll set the username field to something more generic.
      _.extend(options, { usernameField: 'identifier' });

      // Only load the local strategy if it's enabled in the config
      if (strategies[key]) {
        self.use(new Strategy(options, self.protocols.local.login));
      }
github tilomitra / bedrock / api / services / passport.js View on Github external
github: {
      name: 'GitHub',
      protocol: 'oauth2',
      strategy: require('passport-github').Strategy
      scope: [ 'user', 'gist' ]
      options: {
        clientID: 'CLIENT_ID',
        clientSecret: 'CLIENT_SECRET'
      }
    }
 *
 * For more information on the providers supported by Passport.js, check out:
 * http://passportjs.org/guide/providers/
 *
 */
passport.loadStrategies = function () {
  var self       = this
    , strategies = sails.config.passport;

  Object.keys(strategies).forEach(function (key) {
    var options = { passReqToCallback: true }, Strategy;

    if (key === 'local') {
      // Since we need to allow users to login using both usernames as well as
      // emails, we'll set the username field to something more generic.
      _.extend(options, { usernameField: 'identifier' });

      //Let users override the username and passwordField from the options
      _.extend(options, strategies[key].options || {});

      // Only load the local strategy if it's enabled in the config
      if (strategies.local) {
github kasperisager / sails-generate-auth / templates / api / services / passport.js View on Github external
github: {
      name: 'GitHub',
      protocol: 'oauth2',
      strategy: require('passport-github').Strategy
      scope: [ 'user', 'gist' ]
      options: {
        clientID: 'CLIENT_ID',
        clientSecret: 'CLIENT_SECRET'
      }
    }
 *
 * For more information on the providers supported by Passport.js, check out:
 * http://passportjs.org/guide/providers/
 *
 */
passport.loadStrategies = function () {
  var self       = this
    , strategies = sails.config.passport;

  Object.keys(strategies).forEach(function (key) {
    var options = { passReqToCallback: true }, Strategy;

    if (key === 'local') {
      // Since we need to allow users to login using both usernames as well as
      // emails, we'll set the username field to something more generic.
      _.extend(options, { usernameField: 'identifier' });

      //Let users override the username and passwordField from the options
      _.extend(options, strategies[key].options || {});

      // Only load the local strategy if it's enabled in the config
      if (strategies.local) {
github porybox / porybox / api / services / passport.js View on Github external
github: {
      name: 'GitHub',
      protocol: 'oauth2',
      strategy: require('passport-github').Strategy
      scope: [ 'user', 'gist' ]
      options: {
        clientID: 'CLIENT_ID',
        clientSecret: 'CLIENT_SECRET'
      }
    }
 *
 * For more information on the providers supported by Passport.js, check out:
 * http://passportjs.org/guide/providers/
 *
 */
passport.loadStrategies = function () {
  const self       = this,
    strategies = sails.config.passport;

  Object.keys(strategies).forEach(function (key) {
    const options = { passReqToCallback: true };
    let Strategy;

    if (key === 'local') {

      _.extend(options, { usernameField: 'name' });

      _.extend(options, strategies[key].options || {});

      // Only load the local strategy if it's enabled in the config
      if (strategies.local) {
        Strategy = strategies[key].strategy;
github pantsel / konga / api / services / Passport.js View on Github external
github: {
      name: 'GitHub',
      protocol: 'oauth2',
      scope: [ 'user', 'gist' ]
      options: {
        clientID: 'CLIENT_ID',
        clientSecret: 'CLIENT_SECRET'
      }
    }
 *
 * For more information on the providers supported by Passport.js, check out:
 * http://passportjs.org/guide/providers/
 *
 * @param {Request} request
 */
passport.loadStrategies = function loadStrategies(request) {
  sails.log.verbose(__filename + ':' + __line + ' [Service.Passport.loadStrategies() called]');

  var self = this;
  var strategies = sails.config.passport;

  Object.keys(strategies).forEach(function(key) {
    var options = {passReqToCallback: true};
    var Strategy;

    if (key === 'local') {
      /**
       * Since we need to allow users to login using both usernames as well as
       * emails, we'll set the username field to something more generic.
       */
      _.extend(options, {usernameField: 'identifier'});