We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a4f06ba commit e811dc7Copy full SHA for e811dc7
templates/mongoshrc.js.erb
@@ -19,7 +19,7 @@ function rsReconfigSettings(settings){
19
<% if @auth and @store_creds -%>
20
function authRequired() {
21
try {
22
- return db.serverCmdLineOpts().code == 13;
+ return db.serverCmdLineOpts().ok != 1;
23
} catch (err) {
24
if (err.message.match(/requires authentication/) || err.message.match(/not authorized on admin/)) {
25
return true
@@ -35,7 +35,7 @@ if (authRequired()) {
35
db.getMongo().setReadPref('primaryPreferred')
36
<%- end -%>
37
38
- var prev_db = db
+ var prev_db = db.getName()
39
db = db.getSiblingDB('admin')
40
db.auth('<%= @admin_username %>', '<%= @admin_password_unsensitive %>')
41
db = db.getSiblingDB(prev_db)
0 commit comments