Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added missing authentication parameters to DendroMongoClient construc…
…tor call.
  • Loading branch information
silvae86 committed Sep 12, 2018
1 parent ca46910 commit 6726d80
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/controllers/admin.js
Expand Up @@ -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))
Expand Down
6 changes: 4 additions & 2 deletions src/kb/mongo.js
Expand Up @@ -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)
{
Expand All @@ -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)
Expand All @@ -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);
});
};
Expand All @@ -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);
});
};
Expand Down
2 changes: 1 addition & 1 deletion src/models/user.js
Expand Up @@ -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)
{
Expand Down
Expand Up @@ -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))
Expand Down
Expand Up @@ -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))
Expand Down

0 comments on commit 6726d80

Please sign in to comment.