@@ -180,12 +180,7 @@ Multi.prototype.info = Multi.prototype.INFO = function info (section, callback)
180
180
return this ;
181
181
} ;
182
182
183
- function auth_callback ( self , user , pass , callback ) {
184
- // Backward compatibility support for auth with password only
185
- if ( user instanceof Function ) {
186
- callback = user ;
187
- user = null ;
188
- }
183
+ function auth_callback ( self , pass , user , callback ) {
189
184
return function ( err , res ) {
190
185
if ( err ) {
191
186
if ( no_password_is_set . test ( err . message ) ) {
@@ -205,7 +200,7 @@ function auth_callback (self, user, pass, callback) {
205
200
} ;
206
201
}
207
202
208
- RedisClient . prototype . auth = RedisClient . prototype . AUTH = function auth ( user , pass , callback ) {
203
+ RedisClient . prototype . auth = RedisClient . prototype . AUTH = function auth ( pass , user , callback ) {
209
204
debug ( 'Sending auth to ' + this . address + ' id ' + this . connection_id ) ;
210
205
211
206
// Backward compatibility support for auth with password only
@@ -220,16 +215,16 @@ RedisClient.prototype.auth = RedisClient.prototype.AUTH = function auth (user, p
220
215
this . ready = ready || this . offline_queue . length === 0 ;
221
216
var tmp ;
222
217
if ( user ) {
223
- tmp = this . internal_send_command ( new Command ( 'auth' , [ user , pass ] , auth_callback ( this , user , pass , callback ) ) ) ;
218
+ tmp = this . internal_send_command ( new Command ( 'auth' , [ user , pass ] , auth_callback ( this , pass , user , callback ) ) ) ;
224
219
} else {
225
- tmp = this . internal_send_command ( new Command ( 'auth' , [ pass ] , auth_callback ( this , pass , callback ) ) ) ;
220
+ tmp = this . internal_send_command ( new Command ( 'auth' , [ pass ] , auth_callback ( this , pass , user , callback ) ) ) ;
226
221
}
227
222
this . ready = ready ;
228
223
return tmp ;
229
224
} ;
230
225
231
226
// Only works with batch, not in a transaction
232
- Multi . prototype . auth = Multi . prototype . AUTH = function auth ( user , pass , callback ) {
227
+ Multi . prototype . auth = Multi . prototype . AUTH = function auth ( pass , user , callback ) {
233
228
debug ( 'Sending auth to ' + this . address + ' id ' + this . connection_id ) ;
234
229
235
230
// Backward compatibility support for auth with password only
@@ -240,11 +235,7 @@ Multi.prototype.auth = Multi.prototype.AUTH = function auth (user, pass, callbac
240
235
// Stash auth for connect and reconnect.
241
236
this . auth_pass = pass ;
242
237
this . auth_user = user ;
243
- if ( user ) {
244
- this . queue . push ( new Command ( 'auth' , [ user , pass ] , auth_callback ( this . _client , callback ) ) ) ;
245
- } else {
246
- this . queue . push ( new Command ( 'auth' , [ pass ] , auth_callback ( this . _client , callback ) ) ) ;
247
- }
238
+ this . queue . push ( new Command ( 'auth' , user ? [ user , pass ] : [ pass ] , auth_callback ( this . _client , pass , user , callback ) ) ) ;
248
239
return this ;
249
240
} ;
250
241
0 commit comments