Modified setup script to search for admin user by email AND username

This commit is contained in:
David Baldwynn 2017-11-21 12:37:57 -08:00
parent c97f207699
commit 563b8c6cd2
2 changed files with 10 additions and 15 deletions

View File

@ -63,7 +63,7 @@ var createOrUpdateAdminUser = function(username, email, password, cb){
setDefaultsOnInsert: true
}
User.findOneAndUpdate({ username: username }, updateObj, options, function (err, result) {
User.findOneAndUpdate({ username: username, email: email }, updateObj, options, function (err, result) {
if (err) {
return cb(err);
}

View File

@ -1,19 +1,19 @@
var constants = require('../app/libs/constants');
var createRegexValidator = function(regex){
var createRegexValidator = function(regex, message){
return function(value) {
var isValid = new RegExp(regex, 'g').test(value);
if(!isValid){
return 'Please enter a valid email'
return message
} else {
return true;
}
}
}
var validateEmail = createRegexValidator(constants.regex.email);
var validateUsername = createRegexValidator(constants.regex.username);
var validateEmail = createRegexValidator(constants.regex.email, 'Please enter a valid email');
var validateUsername = createRegexValidator(constants.regex.username, 'Usernames can only contain alphanumeric characters and \'-\'');
module.exports = {
replaceENVQuestion: {
@ -105,11 +105,6 @@ module.exports = {
type: 'password',
name: 'MAILER_PASSWORD',
message: 'What is your SMTP password?'
},
{
type: 'input',
name: 'MAILER_FROM',
message: 'What do you want the default "from" email address to be?'
}
],
@ -143,16 +138,16 @@ module.exports = {
type: 'password',
name: 'MAILER_PASSWORD',
message: 'What is your SMTP password?'
},
}
],
questionsPart2: [
{
type: 'input',
name: 'MAILER_FROM',
message: 'What do you want the default "from" email address to be?',
validate: validateEmail
}
],
questionsPart2: [
},
{
type: 'input',
name: 'MONGODB_URI',