Permalink
Browse files

Patch adding authentication to MongoDb store, documentation pending

  • Loading branch information...
hannesgassert committed Jan 13, 2012
1 parent e6b67f1 commit 700126a2ac6f9053669d0e9b463ec5ca9e063280
Showing with 23 additions and 9 deletions.
  1. +23 −9 lib/stores/mongodb.js
View
@@ -55,20 +55,34 @@ module.exports = function (options) {
callback(err, collection); callback(err, collection);
} }
function collectionSetup() {
STORE.db.collection(options.collection || 'translations', function (err, collection) {
if (collection) {
connect(err, collection);
} else {
STORE.db.createCollection(options.collection || 'translations', function (err, collection) {
connect(err, collection);
});
}
});
}
if (!_is_connected) { if (!_is_connected) {
STORE.db.open(function (err, db) { STORE.db.open(function (err, db) {
if (err) { if (err) {
callback(err, null); callback(err, null);
} else { } else {
STORE.db.collection(options.collection || 'translations', function (err, collection) { if (options.username && options.password) {
if (collection) { db.authenticate(options.username, options.password, function (err) {
connect(err, collection); if (err) {
} else { callback(err, null);
STORE.db.createCollection(options.collection || 'translations', function (err, collection) { } else {
connect(err, collection); collectionSetup();
}); }
} });
}); } else {
collectionSetup();
}
} }
}); });
} }

0 comments on commit 700126a

Please sign in to comment.