Skip to content

Commit 1aa87e6

Browse files
committed
reverse password user order
1 parent f946e13 commit 1aa87e6

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function RedisClient (options, stream) {
109109
this.closing = false;
110110
this.server_info = {};
111111
this.auth_pass = options.auth_pass || options.password;
112-
this.auth_user = options.auth_user;
112+
this.auth_user = options.auth_user || options.user;
113113
this.selected_db = options.db; // Save the selected db here, used when reconnecting
114114
this.fire_strings = true; // Determine if strings or buffers should be written to the stream
115115
this.pipeline = false;
@@ -241,7 +241,7 @@ RedisClient.prototype.create_stream = function () {
241241
if (this.auth_pass !== undefined) {
242242
this.ready = true;
243243
// Fail silently as we might not be able to connect
244-
this.auth(this.auth_pass, this.auth_user, function (err) {
244+
this.auth(this.auth_user, this.auth_pass, function (err) {
245245
if (err && err.code !== 'UNCERTAIN_STATE') {
246246
self.emit('error', err);
247247
}

lib/individualCommands.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ Multi.prototype.info = Multi.prototype.INFO = function info (section, callback)
180180
return this;
181181
};
182182

183-
function auth_callback (self, pass, user, callback) {
183+
function auth_callback (self, user, pass, callback) {
184184
// Backward compatibility support for auth with password only
185185
if (user instanceof Function) {
186186
callback = user;
@@ -196,7 +196,7 @@ function auth_callback (self, pass, user, callback) {
196196
// If redis is still loading the db, it will not authenticate and everything else will fail
197197
debug('Redis still loading, trying to authenticate later');
198198
setTimeout(function () {
199-
self.auth(pass, user, callback);
199+
self.auth(user, pass, callback);
200200
}, 100);
201201
return;
202202
}
@@ -205,7 +205,7 @@ function auth_callback (self, pass, user, callback) {
205205
};
206206
}
207207

208-
RedisClient.prototype.auth = RedisClient.prototype.AUTH = function auth (pass, user, callback) {
208+
RedisClient.prototype.auth = RedisClient.prototype.AUTH = function auth (user, pass, callback) {
209209
debug('Sending auth to ' + this.address + ' id ' + this.connection_id);
210210

211211
// Backward compatibility support for auth with password only
@@ -220,7 +220,7 @@ RedisClient.prototype.auth = RedisClient.prototype.AUTH = function auth (pass, u
220220
this.ready = ready || this.offline_queue.length === 0;
221221
var tmp;
222222
if (user) {
223-
tmp = this.internal_send_command(new Command('auth', [pass, user], auth_callback(this, pass, user, callback)));
223+
tmp = this.internal_send_command(new Command('auth', [user, pass], auth_callback(this, user, pass, callback)));
224224
} else {
225225
tmp = this.internal_send_command(new Command('auth', [pass], auth_callback(this, pass, callback)));
226226
}
@@ -229,7 +229,7 @@ RedisClient.prototype.auth = RedisClient.prototype.AUTH = function auth (pass, u
229229
};
230230

231231
// Only works with batch, not in a transaction
232-
Multi.prototype.auth = Multi.prototype.AUTH = function auth (pass, user, callback) {
232+
Multi.prototype.auth = Multi.prototype.AUTH = function auth (user, pass, callback) {
233233
debug('Sending auth to ' + this.address + ' id ' + this.connection_id);
234234

235235
// Backward compatibility support for auth with password only
@@ -241,7 +241,7 @@ Multi.prototype.auth = Multi.prototype.AUTH = function auth (pass, user, callbac
241241
this.auth_pass = pass;
242242
this.auth_user = user;
243243
if (user) {
244-
this.queue.push(new Command('auth', [pass, user], auth_callback(this._client, callback)));
244+
this.queue.push(new Command('auth', [user, pass], auth_callback(this._client, callback)));
245245
} else {
246246
this.queue.push(new Command('auth', [pass], auth_callback(this._client, callback)));
247247
}

0 commit comments

Comments
 (0)