trailsjs / sails-auth

Passport-based User Authentication system for sails.js applications. Designed to work well with the sails-permissions module.
https://www.npmjs.org/package/sails-auth
MIT License
265 stars 141 forks source link

How to define passport config for different environments #77

Open loulin opened 8 years ago

loulin commented 8 years ago

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
      }
    },
  }

});
kevintechie commented 8 years ago

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