Fix conflict

This commit is contained in:
Jim Laurie 2018-01-25 10:02:17 +01:00
commit 2e1283f117
6 changed files with 47 additions and 12 deletions

View File

@ -1,4 +1,16 @@
**Node.js version**:
**npm version**:
**Strapi version**:
**Operating system**:
**Do you want to request a *feature* or report a *bug*?**
**What is the current behavior?**
**If the current behavior is a bug, please provide the steps to reproduce the problem**
**What is the expected behavior?**

View File

@ -8,8 +8,8 @@
"host": "${process.env.DATABASE_HOST || 'localhost'}",
"port": "${process.env.DATABASE_PORT || 27017}",
"database": "${process.env.DATABASE_NAME || 'production'}",
"username": "",
"password": ""
"username": "${process.env.DATABASE_USERNAME || ''}",
"password": "${process.env.DATABASE_PASSWORD || ''}"
},
"options": {}
}

View File

@ -15,6 +15,7 @@ const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPl
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const isAdmin = process.env.IS_ADMIN === 'true';
const isSetup = path.resolve(process.env.PWD, '..', '..') === path.resolve(process.env.INIT_CWD);
const appPath = (() => {
if (process.env.APP_PATH) {
return process.env.APP_PATH;
@ -22,7 +23,13 @@ const appPath = (() => {
return isAdmin ? path.resolve(process.env.PWD, '..') : path.resolve(process.env.PWD, '..', '..');
})();
const isSetup = path.resolve(process.env.PWD, '..', '..') === path.resolve(process.env.INIT_CWD);
const rootAdminpath = (() => {
if (isSetup) {
return isAdmin ? path.resolve(appPath, 'strapi-admin') : path.resolve(appPath, 'packages', 'strapi-admin');
}
return path.resolve(appPath, 'admin');
})();
// Load plugins into the same build in development mode.
const plugins = {

View File

@ -43,11 +43,14 @@ module.exports = function (strapi) {
const { host, port, username, password, database } = _.defaults(connection.settings, strapi.config.hook.settings.mongoose);
// Connect to mongo database
if (_.isEmpty(username) || _.isEmpty(password)) {
instance.connect(`mongodb://${host}:${port}/${database}`);
} else {
instance.connect(`mongodb://${username}:${password}@${host}:${port}/${database}`);
const connectOptions = {}
if (!_.isEmpty(username)) {
connectOptions.user = username
if (!_.isEmpty(password)) {
connectOptions.pass = password
}
}
instance.connect(`mongodb://${host}:${port}/${database}`, connectOptions);
// Handle error
instance.connection.on('error', error => {

View File

@ -9,8 +9,16 @@ const logger = require('strapi-utils').logger;
module.exports = (scope, success, error) => {
const Mongoose = require(path.resolve(`${scope.rootPath}/node_modules/mongoose`));
Mongoose.connect(`mongodb://${ (scope.database.settings.username && scope.database.settings.password) ? `${scope.database.settings.username}:${scope.database.settings.password}@` : '' }${scope.database.settings.host}:${scope.database.settings.port}/${scope.database.settings.database}`, function (err) {
const { username, password } = scope.database.settings
const connectOptions = {}
if (username) {
connectOptions.user = username
if (password) {
connectOptions.pass = password
}
}
Mongoose.connect(`mongodb://${scope.database.settings.host}:${scope.database.settings.port}/${scope.database.settings.database}`, connectOptions, function (err) {
if (err) {
logger.warn('Database connection has failed! Make sure your database is running.');
return error();

View File

@ -8,7 +8,7 @@
const _ = require('lodash');
const crypto = require('crypto');
const Grant = require('grant-koa');
const emailRegExp = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
module.exports = {
callback: async (ctx) => {
@ -33,11 +33,11 @@ module.exports = {
const query = {};
// Check if the provided identifier is an email or not.
const isEmail = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(params.identifier);
const isEmail = emailRegExp.test(params.identifier);
// Set the identifier to the appropriate query field.
if (isEmail) {
query.email = params.identifier;
query.email = params.identifier.toLowerCase();
} else {
query.username = params.identifier;
}
@ -207,6 +207,11 @@ module.exports = {
params.role = '1';
}
// Check if the provided identifier is an email or not.
const isEmail = emailRegExp.test(params.identifier);
if (isEmail) {
params.identifier = params.identifier.toLowerCase();
}
params.password = await strapi.plugins['users-permissions'].services.user.hashPassword(params);
const user = await strapi.query('user', 'users-permissions').findOne({