Skip to content

Node.js based forum software built for the modern web

added authentication to mongo

Baris Usakli351b07bb3470
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'