sails-auth
sails-auth copied to clipboard
How to define passport config for different environments
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
}
},
}
});
I require the appropriate environment js files based on the current process.env.NODE_ENV value.