Skip to content

Loading…

MongoDB 2.4.1 support #131

Merged
merged 1 commit into from

2 participants

@outaTiME

Hi pal,

i make a little fix to support a forced connection for MongoDB 2.4.1, im running in heroku and 1 week ago MongoHQ update our databases and errmsg updated to unauthorized.

thks!

@fzaninotto fzaninotto merged commit 0b5da35 into fzaninotto:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 6, 2013
  1. @outaTiME
Showing with 3 additions and 3 deletions.
  1. +3 −3 bootstrap.js
View
6 bootstrap.js
@@ -10,9 +10,9 @@ mongoose.connection.on('error', function (err) {
process.exit(1);
});
mongoose.connection.on('open', function (err) {
- mongoose.connection.db.admin().serverStatus(function(err, data) {
+ mongoose.connection.db.admin().serverStatus(function(err, data) {
if (err) {
- if (err.name === "MongoError" && err.errmsg === 'need to login') {
+ if (err.name === "MongoError" && (err.errmsg === 'need to login' || err.errmsg === 'unauthorized')) {
console.log('Forcing MongoDB authentication');
mongoose.connection.db.authenticate(config.mongodb.user, config.mongodb.password, function(err) {
if (!err) return;
@@ -33,4 +33,4 @@ mongoose.connection.on('open', function (err) {
});
-module.exports = mongoose;
+module.exports = mongoose;
Something went wrong with that request. Please try again.