Permalink
Browse files

Added missing authentication parameters to DendroMongoClient construc…

…tor call.
  • Loading branch information...
silvae86 committed Sep 12, 2018
1 parent ca46910 commit 6726d8047bacd1226f02c54bf5838b42f43ea3bb
@@ -604,7 +604,7 @@ module.exports.restartServer = function (req, res)
const listOrphanResourcesAux = function (callback)
{
let mongoClient = new DendroMongoClient(Config.mongoDBHost, Config.mongoDbPort, Config.mongoDbCollectionName);
let mongoClient = new DendroMongoClient(Config.mongoDBHost, Config.mongoDbPort, Config.mongoDbCollectionName, Config.mongoDBAuth.username, Config.mongoDBAuth.password);
mongoClient.connect(function (err, mongoDb)
{
if (isNull(err) && !isNull(mongoDb))
@@ -3,6 +3,7 @@ const slug = rlequire("dendro", "src/utils/slugifier.js");
const isNull = rlequire("dendro", "src/utils/null.js").isNull;
const MongoClient = require("mongodb").MongoClient;
const Logger = rlequire("dendro", "src/utils/logger.js").Logger;
function DendroMongoClient (mongoDBHost, mongoDbPort, mongoDbCollectionName, mongoDbUsername, mongoDbPassword)
{
@@ -29,6 +30,7 @@ DendroMongoClient.prototype.connect = function (callback)
url = "mongodb://" + self.host + ":" + self.port + "/" + self.collectionName;
}
Logger.log("debug", "Connecting to MongoDB using connection string: " + url);
MongoClient.connect(url, function (err, db)
{
if (!err)
@@ -49,7 +51,7 @@ DendroMongoClient.prototype.findFileByFilenameOrderedByDate = function (db, file
{
return callback(null, files);
}
const msg = "Error findind document with uri: " + fileUri + " in Mongo error: " + JSON.stringify(err);
const msg = "Error finding document with uri: " + fileUri + " in Mongo. error: " + JSON.stringify(err);
return callback(true, msg);
});
};
@@ -64,7 +66,7 @@ DendroMongoClient.prototype.getNonAvatarNorThumbnailFiles = function (db, callba
{
return callback(null, files);
}
const msg = "Error when looking for non Avatar nor thumbnail files in Mongo, error: " + JSON.stringify(err);
const msg = "Error when looking for non Avatar nor thumbnail files in Mongo. error: " + JSON.stringify(err);
return callback(true, msg);
});
};
@@ -1222,7 +1222,7 @@ User.prototype.saveAvatarInGridFS = function (avatar, extension, callback)
let avatarUri = "/avatar/" + self.ddr.username + "/avatar." + extension;
let base64Data = avatar.replace(/^data:image\/png;base64,/, "");
let mongoClient = new DendroMongoClient(Config.mongoDBHost, Config.mongoDbPort, Config.mongoDbCollectionName);
let mongoClient = new DendroMongoClient(Config.mongoDBHost, Config.mongoDbPort, Config.mongoDbCollectionName, Config.mongoDBAuth.username, Config.mongoDBAuth.password);
mongoClient.connect(function (err, mongoDb)
{
@@ -33,7 +33,7 @@ let agent;
checkFileExistsInGridFs = function (fileUri, callback)
{
const DendroMongoClient = rlequire("dendro", "src/kb/mongo.js").DendroMongoClient;
let mongoClient = new DendroMongoClient(Config.mongoDBHost, Config.mongoDbPort, Config.mongoDbCollectionName);
let mongoClient = new DendroMongoClient(Config.mongoDBHost, Config.mongoDbPort, Config.mongoDbCollectionName, Config.mongoDBAuth.username, Config.mongoDBAuth.password);
mongoClient.connect(function (err, mongoDb)
{
if (isNull(err) && !isNull(mongoDb))
@@ -33,7 +33,7 @@ let agent;
checkFileExistsInGridFs = function (fileUri, callback)
{
const DendroMongoClient = rlequire("dendro", "src/kb/mongo.js").DendroMongoClient;
let mongoClient = new DendroMongoClient(Config.mongoDBHost, Config.mongoDbPort, Config.mongoDbCollectionName);
let mongoClient = new DendroMongoClient(Config.mongoDBHost, Config.mongoDbPort, Config.mongoDbCollectionName, Config.mongoDBAuth.username, Config.mongoDBAuth.password);
mongoClient.connect(function (err, mongoDb)
{
if (isNull(err) && !isNull(mongoDb))

0 comments on commit 6726d80

Please sign in to comment.