From 351b07bb3470340e090a36f5435a65d5e532db26 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Fri, 6 Dec 2013 14:31:11 -0500 Subject: [PATCH] added authentication to mongo --- src/database/mongo.js | 12 ++++++++---- src/install.js | 3 +++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/database/mongo.js b/src/database/mongo.js index b31d99b558..211040ad2d 100644 --- a/src/database/mongo.js +++ b/src/database/mongo.js @@ -28,10 +28,14 @@ // TODO : what is the db user name?? - /*if(nconf.get('mongo:password')) { - db.authenticate(dbUser, nconf.get('mongo:password'), function (err) { + if(nconf.get('mongo:password') && nconf.get('mongo:username')) { + db.authenticate(nconf.get('mongo:username'), nconf.get('mongo:password'), function (err) { + if(err) { + winston.error(err.message); + } + process.exit(); }); - }*/ + } db.createCollection('objects', function(err, collection) { @@ -60,7 +64,7 @@ } }); } - }) + }); callback(err); }); diff --git a/src/install.js b/src/install.js index f7583c81fb..4deca311cd 100644 --- a/src/install.js +++ b/src/install.js @@ -64,6 +64,9 @@ var async = require('async'), name: 'mongo:port', description: 'Host port of your MongoDB instance', 'default': nconf.get('mongo:port') || 27017 + }, { + name: 'mongo:user', + description: 'MongoDB username' }, { name: 'mongo:password', description: 'Password of your MongoDB database'