Skip to content

Commit a9d565b

Browse files
author
Ruben Bridgewater
committed
Fix auth regression
Fixes #1028
1 parent aff765a commit a9d565b

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ RedisClient.prototype.create_stream = function () {
269269

270270
// Fire the command before redis is connected to be sure it's the first fired command
271271
if (this.auth_pass !== undefined) {
272+
this.ready = true;
272273
this.auth(this.auth_pass);
274+
this.ready = false;
273275
}
274276
};
275277

lib/individualCommands.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ RedisClient.prototype.auth = RedisClient.prototype.AUTH = function auth (pass, c
149149

150150
// Stash auth for connect and reconnect.
151151
this.auth_pass = pass;
152-
this.ready = this.offline_queue.length === 0; // keep the execution order intakt
152+
this.ready = ready || this.offline_queue.length === 0; // keep the execution order intakt
153153
var tmp = this.internal_send_command('auth', [pass], function (err, res) {
154154
if (err) {
155155
if (no_password_is_set.test(err.message)) {

test/auth.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ describe('client authentication', function () {
160160
client.on('ready', done);
161161
});
162162

163-
it('reconnects with appropriate authentication', function (done) {
163+
it('reconnects with appropriate authentication while offline commands are present', function (done) {
164164
if (helper.redisProcess().spawnFailed()) this.skip();
165165

166166
client = redis.createClient.apply(null, args);
@@ -187,7 +187,7 @@ describe('client authentication', function () {
187187
});
188188
});
189189

190-
it('should return an error if the password is not of type string and a callback has been provided', function (done) {
190+
it('should return an error if the password is not correct and a callback has been provided', function (done) {
191191
if (helper.redisProcess().spawnFailed()) this.skip();
192192

193193
client = redis.createClient.apply(null, args);
@@ -202,7 +202,7 @@ describe('client authentication', function () {
202202
assert(async);
203203
});
204204

205-
it('should emit an error if the password is not of type string and no callback has been provided', function (done) {
205+
it('should emit an error if the password is not correct and no callback has been provided', function (done) {
206206
if (helper.redisProcess().spawnFailed()) this.skip();
207207

208208
client = redis.createClient.apply(null, args);

0 commit comments

Comments
 (0)