You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Fix redis 2.4 auth support
This commit is contained in:
@@ -4,6 +4,7 @@ var utils = require('./utils');
|
||||
var debug = require('./debug');
|
||||
var Multi = require('./multi');
|
||||
var no_password_is_set = /no password is set/;
|
||||
var loading = /LOADING/;
|
||||
var RedisClient = require('../').RedisClient;
|
||||
|
||||
/********************************
|
||||
@@ -91,12 +92,20 @@ RedisClient.prototype.auth = RedisClient.prototype.AUTH = function auth (pass, c
|
||||
this.auth_pass = pass;
|
||||
this.ready = this.offline_queue.length === 0; // keep the execution order intakt
|
||||
var tmp = this.send_command('auth', [pass], function (err, res) {
|
||||
if (err && no_password_is_set.test(err.message)) {
|
||||
self.warn('Warning: Redis server does not require a password, but a password was supplied.');
|
||||
err = null;
|
||||
res = 'OK';
|
||||
if (err) {
|
||||
if (no_password_is_set.test(err.message)) {
|
||||
self.warn('Warning: Redis server does not require a password, but a password was supplied.');
|
||||
err = null;
|
||||
res = 'OK';
|
||||
} else if (loading.test(err.message)) {
|
||||
// If redis is still loading the db, it will not authenticate and everything else will fail
|
||||
debug('Redis still loading, trying to authenticate later');
|
||||
setTimeout(function () {
|
||||
self.auth(pass, callback);
|
||||
}, 200);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
utils.callback_or_emit(self, callback, err, res);
|
||||
});
|
||||
this.ready = ready;
|
||||
|
Reference in New Issue
Block a user