Skip to content

Commit 9aff345

Browse files
committed
😡 switch back to retry hack as the driver throws an error if DEFAULT is used
1 parent eb735cb commit 9aff345

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

src/connect/auth-fields.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ var service_name = new InputView({
6262
* Define fields for each auth method here
6363
*/
6464
module.exports = {
65-
DEFAULT: [
65+
'SCRAM-SHA-1': [
6666
username,
6767
password,
6868
database_name
6969
],
70-
7170
GSSAPI: [
7271
username,
7372
service_name

src/connect/index.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ var ConnectView = View.extend({
150150
evt.preventDefault();
151151
this.toggle('authOpen');
152152
if (this.authOpen) {
153-
this.authMethod = this.previousAuthMethod || 'DEFAULT';
153+
this.authMethod = this.previousAuthMethod || 'SCRAM-SHA-1';
154154
} else {
155155
this.authMethod = null;
156156
}
@@ -234,13 +234,31 @@ var ConnectView = View.extend({
234234

235235
debug('testing credentials are usable...');
236236
model.test(function(err) {
237-
app.statusbar.hide();
238-
if (err) {
237+
if (!err) {
238+
this.onConnectionSuccessful(model, options);
239+
return;
240+
}
241+
242+
if (model.auth_mechanism !== 'SCRAM-SHA-1') {
239243
debug('failed to connect', err);
240244
this.onError(new Error('Could not connect to MongoDB.'), model);
241245
return;
242246
}
243-
this.onConnectionSuccessful(model, options);
247+
248+
// For Kernel 2.6.x
249+
model.auth_mechanism = 'MONGODB-CR';
250+
debug('trying again w/ MONGODB-CR...');
251+
app.statusbar.show();
252+
253+
model.test(function(err) {
254+
if (err) {
255+
debug('failed to connect again... bailing', err);
256+
this.onError(new Error('Could not connect to MongoDB.'), model);
257+
return;
258+
}
259+
this.onConnectionSuccessful(model, options);
260+
}.bind(this));
261+
244262
}.bind(this));
245263
},
246264
/**
@@ -375,7 +393,7 @@ var ConnectView = View.extend({
375393
// @todo (imlucas): Consolidate w/ `./auth-fields.js`.
376394
var authMethods = [
377395
{
378-
_id: 'DEFAULT',
396+
_id: 'SCRAM-SHA-1',
379397
title: 'User/Password',
380398
enabled: true
381399
},

0 commit comments

Comments
 (0)