moved bcrpyt rounds to config file

v1.18.x
Baris Usakli 12 years ago
parent 93653e88df
commit d66aef7812

@ -114,56 +114,60 @@ fs.readFile(path.join(__dirname, 'config.json'), function(err, data) {
ask('... the host port of your Redis instance? (6379)', function(redis_port) { ask('... the host port of your Redis instance? (6379)', function(redis_port) {
ask('... the password of your Redis database? (no password)', function(redis_password) { ask('... the password of your Redis database? (no password)', function(redis_password) {
ask('... your NodeBB secret? (keyboard mash for a bit here)', function(secret) { ask('... your NodeBB secret? (keyboard mash for a bit here)', function(secret) {
if (!base_url) base_url = 'http://localhost'; ask('... the number of rounds to use for bcrypt.genSalt? (10)', function(bcrypt_rounds) {
if (!port) port = 4567; if (!base_url) base_url = 'http://localhost';
if (!use_port) use_port = true; else use_port = (use_port === 'y' ? true : false); if (!port) port = 4567;
if (!redis_host) redis_host = '127.0.0.1'; if (!use_port) use_port = true; else use_port = (use_port === 'y' ? true : false);
if (!redis_port) redis_port = 6379; if (!redis_host) redis_host = '127.0.0.1';
if (!secret) secret = utils.generateUUID(); if (!redis_port) redis_port = 6379;
if (!secret) secret = utils.generateUUID();
var fs = require('fs'), if (!bcrypt_rounds) bcrypt_rounds = 10;
path = require('path'),
config = { var fs = require('fs'),
secret: secret, path = require('path'),
base_url: base_url, config = {
port: port, secret: secret,
use_port: use_port, base_url: base_url,
upload_path: '/public/uploads/', port: port,
redis: { use_port: use_port,
host: redis_host, upload_path: '/public/uploads/',
port: redis_port, bcrypt_rounds: bcrypt_rounds,
password: redis_password redis: {
host: redis_host,
port: redis_port,
password: redis_password
}
} }
}
// Server-side config
// Server-side config fs.writeFile(path.join(__dirname, 'config.json'), JSON.stringify(config, null, 4), function(err) {
fs.writeFile(path.join(__dirname, 'config.json'), JSON.stringify(config, null, 4), function(err) { if (err) throw err;
if (err) throw err; else {
else { process.stdout.write(
process.stdout.write( "\n\nConfiguration Saved OK\n\n"
"\n\nConfiguration Saved OK\n\n" );
); if (!args.setup) {
if (!args.setup) { process.stdout.write(
"Please start NodeBB again and register a new user at " +
base_url + (use_port ? ':' + port : '') + "/register. This user will automatically become an administrator.\n\n"
);
}
process.stdout.write( process.stdout.write(
"Please start NodeBB again and register a new user at " + "If at any time you'd like to run this setup again, run the app with the \"--setup\" flag\n\n"
base_url + (use_port ? ':' + port : '') + "/register. This user will automatically become an administrator.\n\n"
); );
process.exit();
} }
process.stdout.write( });
"If at any time you'd like to run this setup again, run the app with the \"--setup\" flag\n\n"
); // Client-side config
process.exit(); fs.writeFile(path.join(__dirname, 'public', 'config.json'), JSON.stringify({
} socket: {
address: base_url,
port: port
},
api_url: base_url + (use_port ? ':' + port : '') + '/api/'
}, null, 4));
}); });
// Client-side config
fs.writeFile(path.join(__dirname, 'public', 'config.json'), JSON.stringify({
socket: {
address: base_url,
port: port
},
api_url: base_url + (use_port ? ':' + port : '') + '/api/'
}, null, 4))
}); });
}); });
}); });

@ -357,10 +357,7 @@ var utils = require('./../public/src/utils.js'),
return; return;
} }
// round count should be variable somewhere instead of hardcoded here bcrypt.genSalt(config.bcrypt_rounds, function(err, salt) {
// if an admin has the resources to up the round count, then making it easy for them to do so
// can't hurt
bcrypt.genSalt(10, function(err, salt) {
bcrypt.hash(password, salt, function(err, hash) { bcrypt.hash(password, salt, function(err, hash) {
callback(hash); callback(hash);
}); });
@ -391,7 +388,7 @@ var utils = require('./../public/src/utils.js'),
} }
User.onNewPostMade = function(uid, tid, pid, timestamp) { User.onNewPostMade = function(uid, tid, pid, timestamp) {
User.addPostIdToUser(uid, pid) User.addPostIdToUser(uid, pid);
User.incrementUserFieldBy(uid, 'postcount', 1); User.incrementUserFieldBy(uid, 'postcount', 1);
User.setUserField(uid, 'lastposttime', timestamp); User.setUserField(uid, 'lastposttime', timestamp);

Loading…
Cancel
Save