mirror of
https://github.com/strapi/strapi.git
synced 2025-08-12 02:38:21 +00:00
Update branch
Merge branch 'fix/overlay-blocker-stm' of github.com:strapi/strapi into fix/overlay-blocker-stm
This commit is contained in:
commit
1e81d96e91
@ -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 => {
|
||||
|
@ -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();
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
const _ = require('lodash');
|
||||
const crypto = require('crypto');
|
||||
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) => {
|
||||
@ -28,11 +29,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;
|
||||
}
|
||||
@ -170,6 +171,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);
|
||||
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user