sails-auth icon indicating copy to clipboard operation
sails-auth copied to clipboard

How to define passport config for different environments

Open loulin opened this issue 10 years ago • 1 comments

For example, I have different Github configs defined in env/development.js and env/production.js. The following setting will not work because sails is not initialised then.

// config/passport.js

var _ = require('lodash');
var _super = require('sails-permissions/config/passport');

_.merge(exports, _super);
_.merge(exports, {

  passport: {
    github: {
      name: 'GitHub',
      protocol: 'oauth2',
      strategy: require('passport-github').Strategy,
      options: {
        clientID: sails.config.github.clientID,
        clientSecret: sails.config.github.clientSecret
      }
    },
  }

});

loulin avatar Aug 10 '15 12:08 loulin

I require the appropriate environment js files based on the current process.env.NODE_ENV value.

kevintechie avatar Aug 11 '15 16:08 kevintechie