|
|
|
@ -277,18 +277,32 @@ var async = require('async'),
|
|
|
|
|
description: 'Administrator email address',
|
|
|
|
|
pattern: /.+@.+/,
|
|
|
|
|
required: true
|
|
|
|
|
}, {
|
|
|
|
|
}],
|
|
|
|
|
passwordQuestions = [{
|
|
|
|
|
name: 'password',
|
|
|
|
|
description: 'Password',
|
|
|
|
|
required: true,
|
|
|
|
|
hidden: true,
|
|
|
|
|
type: 'string'
|
|
|
|
|
}, {
|
|
|
|
|
name: 'password:confirm',
|
|
|
|
|
description: 'Confirm Password',
|
|
|
|
|
required: true,
|
|
|
|
|
hidden: true,
|
|
|
|
|
type: 'string'
|
|
|
|
|
}],
|
|
|
|
|
success = function(err, results) {
|
|
|
|
|
if (!results) {
|
|
|
|
|
return callback(new Error('aborted'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if the passwords match
|
|
|
|
|
if (results['password:confirm'] !== results.password) {
|
|
|
|
|
winston.warn("Passwords did not match, please try again");
|
|
|
|
|
// Re-prompt password questions.
|
|
|
|
|
return retryPassword(results);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nconf.set('bcrypt_rounds', 12);
|
|
|
|
|
User.create(results.username, results.password, results.email, function (err, uid) {
|
|
|
|
|
if (err) {
|
|
|
|
@ -306,8 +320,26 @@ var async = require('async'),
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
retryPassword = function (originalResults) {
|
|
|
|
|
// Ask only the password questions
|
|
|
|
|
prompt.get(passwordQuestions, function (err, results) {
|
|
|
|
|
if (!results) {
|
|
|
|
|
return callback(new Error('aborted'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update the original data with newly collected password
|
|
|
|
|
originalResults.password = results.password;
|
|
|
|
|
originalResults['password:confirm'] = results['password:confirm'];
|
|
|
|
|
|
|
|
|
|
// Send back to success to handle
|
|
|
|
|
success(err, originalResults);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Add the password questions
|
|
|
|
|
questions = questions.concat(passwordQuestions);
|
|
|
|
|
|
|
|
|
|
if (!install.values) prompt.get(questions, success);
|
|
|
|
|
else {
|
|
|
|
|
var results = {
|
|
|
|
|