Skip to content

Commit

Permalink
Fix the read detection to work correctly with MongoDB Atlas
Browse files Browse the repository at this point in the history
  • Loading branch information
sulkaharo committed Nov 14, 2020
1 parent edf432a commit d7f472a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/server/booterror.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function bootError(env, ctx) {
} else {
message = JSON.stringify(_.pick(obj.err, Object.getOwnPropertyNames(obj.err)));
}
return '<dt>' + obj.desc + '</dt><dd>' + message.replace(/\\n/g, '<br/>') + '</dd>';
return '<dt><b>' + obj.desc + '</b></dt><dd>' + message.replace(/\\n/g, '<br/>') + '</dd>';
}).join(' ');

res.render('error.html', {
Expand Down
4 changes: 2 additions & 2 deletions lib/server/bootevent.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function boot (env, language) {
if (err) {
console.info('ERROR CONNECTING TO MONGO', err);
ctx.bootErrors = ctx.bootErrors || [ ];
ctx.bootErrors.push({'desc': 'Unable to connect to Mongo', err: err});
ctx.bootErrors.push({'desc': 'Unable to connect to Mongo', err: err.message});
}
console.log('Mongo Storage system ready');
ctx.store = store;
Expand All @@ -143,7 +143,7 @@ function boot (env, language) {
} catch (err) {
console.info('ERROR CONNECTING TO MONGO', err);
ctx.bootErrors = ctx.bootErrors || [ ];
ctx.bootErrors.push({'desc': 'Unable to connect to Mongo', err: err});
ctx.bootErrors.push({'desc': 'Unable to connect to Mongo', err: err.message});
next();
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/storage/mongo-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function init (env, cb, forceNewConnection) {
mongo.db.command({ connectionStatus: 1 }).then(
result => {
const roles = result.authInfo.authenticatedUserRoles;
if (roles.lenght > 0 && roles[0].role == 'read') {
if (roles.length > 0 && roles[0].role == 'readAnyDatabase') {
console.error('Mongo user is read only');
cb(new Error('MongoDB connection is in read only mode! Go back to MongoDB configuration and check your database user has read and write access.'), null);
}
Expand Down

0 comments on commit d7f472a

Please sign in to comment.