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 e67f403 commit 2a47714Copy full SHA for 2a47714
templates/mongoshrc.js.erb
@@ -19,9 +19,13 @@ 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
- return false;
+ if (err.message.match(/requires authentication/)) {
25
+ return true
26
+ } else {
27
+ throw("Unknown error :" + err)
28
+ }
29
}
30
31
@@ -31,7 +35,7 @@ if (authRequired()) {
35
db.getMongo().setReadPref('primaryPreferred')
32
36
<%- end -%>
33
37
34
- var prev_db = db
38
+ 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