Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d1fcbc1

Browse files
committedMar 26, 2024·
fixup! Use a more suitable method of detecting if authentication is needed
1 parent 621060e commit d1fcbc1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
 

‎templates/mongoshrc.js.erb

+6-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ function authRequired() {
2121
try {
2222
return rs.status().ok != 1;
2323
} catch (err) {
24-
if (err.message.match(/requires authentication/) || err.message.match(/not authorized on admin/)) {
25-
return true
26-
} else {
27-
throw("Unknown error :" + err)
24+
$switch: {
25+
branches: [
26+
{ case: err.message.match(/requires authentication/) || err.message.match(/not authorized on admin/), then: return true },
27+
{ case: err.message.match(/not running with --replSet/), then: return false },
28+
],
29+
default: throw("Unknown error :" + err)
2830
}
2931
}
3032
}

0 commit comments

Comments
 (0)
Please sign in to comment.