mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 08:19:07 +00:00
Merge branch 'master' into enhance/register
This commit is contained in:
commit
31ee1583b4
@ -11,7 +11,8 @@
|
||||
"database": "${process.env.DATABASE_NAME || 'production'}",
|
||||
"username": "${process.env.DATABASE_USERNAME || ''}",
|
||||
"password": "${process.env.DATABASE_PASSWORD || ''}",
|
||||
"ssl": false
|
||||
"ssl": "${process.env.DATABASE_SSL || false}",
|
||||
"authenticationDatabase": "${process.env.DATABASE_AUTHENTICATION_DATABASE || ''}"
|
||||
},
|
||||
"options": {}
|
||||
}
|
||||
|
@ -10,7 +10,8 @@
|
||||
"database": "test",
|
||||
"username": "",
|
||||
"password": "",
|
||||
"ssl": false
|
||||
"ssl": false,
|
||||
"authenticationDatabase": ""
|
||||
},
|
||||
"options": {}
|
||||
}
|
||||
|
@ -194,6 +194,14 @@ module.exports = (scope, cb) => {
|
||||
mask: '*',
|
||||
default: _.get(scope.database, 'password', undefined)
|
||||
},
|
||||
{
|
||||
when: !hasDatabaseConfig,
|
||||
type: 'input',
|
||||
prefix: '',
|
||||
name: 'authenticationDatabase',
|
||||
message: 'Authentication database:',
|
||||
default: _.get(scope.database, 'authenticationDatabase', undefined)
|
||||
},
|
||||
{
|
||||
when: !hasDatabaseConfig,
|
||||
type: 'boolean',
|
||||
@ -214,6 +222,7 @@ module.exports = (scope, cb) => {
|
||||
scope.database.settings.database = answers.database;
|
||||
scope.database.settings.username = answers.username;
|
||||
scope.database.settings.password = answers.password;
|
||||
scope.database.settings.authenticationDatabase = answers.authenticationDatabase;
|
||||
scope.database.settings.ssl = answers.ssl;
|
||||
|
||||
logger.info('Testing database connection...');
|
||||
|
@ -31,6 +31,7 @@ module.exports = function (strapi) {
|
||||
host: 'localhost',
|
||||
port: 27017,
|
||||
database: 'strapi',
|
||||
authenticationDatabase: '',
|
||||
ssl: false
|
||||
},
|
||||
|
||||
@ -41,7 +42,7 @@ module.exports = function (strapi) {
|
||||
initialize: cb => {
|
||||
_.forEach(_.pickBy(strapi.config.connections, {connector: 'strapi-mongoose'}), (connection, connectionName) => {
|
||||
const instance = new Mongoose();
|
||||
const { uri, host, port, username, password, database, ssl } = _.defaults(connection.settings, strapi.config.hook.settings.mongoose);
|
||||
const { uri, host, port, username, password, database, authenticationDatabase, ssl } = _.defaults(connection.settings, strapi.config.hook.settings.mongoose);
|
||||
|
||||
// Connect to mongo database
|
||||
const connectOptions = {}
|
||||
@ -51,6 +52,9 @@ module.exports = function (strapi) {
|
||||
connectOptions.pass = password
|
||||
}
|
||||
}
|
||||
if (!_.isEmpty(authenticationDatabase)) {
|
||||
connectOptions.authSource = authenticationDatabase;
|
||||
}
|
||||
connectOptions.ssl = ssl ? true : false;
|
||||
|
||||
instance.connect(uri || `mongodb://${host}:${port}/${database}`, connectOptions);
|
||||
|
@ -10,7 +10,7 @@ const logger = require('strapi-utils').logger;
|
||||
module.exports = (scope, success, error) => {
|
||||
const Mongoose = require(path.resolve(`${scope.tmpPath}/node_modules/mongoose`));
|
||||
|
||||
const { username, password, ssl } = scope.database.settings
|
||||
const { username, password, authenticationDatabase, ssl } = scope.database.settings
|
||||
const connectOptions = {}
|
||||
if (username) {
|
||||
connectOptions.user = username
|
||||
@ -18,6 +18,9 @@ module.exports = (scope, success, error) => {
|
||||
connectOptions.pass = password
|
||||
}
|
||||
}
|
||||
if (authenticationDatabase) {
|
||||
connectOptions.authSource = authenticationDatabase;
|
||||
}
|
||||
connectOptions.ssl = ssl ? true : false
|
||||
Mongoose.connect(`mongodb://${scope.database.settings.host}:${scope.database.settings.port}/${scope.database.settings.database}`, connectOptions, function (err) {
|
||||
if (err) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user