Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Patch adding authentication to MongoDb store, documentation pending

  • Loading branch information...
commit 700126a2ac6f9053669d0e9b463ec5ca9e063280 1 parent e6b67f1
@hannesgassert hannesgassert authored
Showing with 23 additions and 9 deletions.
  1. +23 −9 lib/stores/mongodb.js
View
32 lib/stores/mongodb.js
@@ -55,20 +55,34 @@ module.exports = function (options) {
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) {
STORE.db.open(function (err, db) {
if (err) {
callback(err, null);
} else {
- 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 (options.username && options.password) {
+ db.authenticate(options.username, options.password, function (err) {
+ if (err) {
+ callback(err, null);
+ } else {
+ collectionSetup();
+ }
+ });
+ } else {
+ collectionSetup();
+ }
}
});
}
Please sign in to comment.
Something went wrong with that request. Please try again.