From 52a0d0459d728a68d0c288ab64fba15601c27c1b Mon Sep 17 00:00:00 2001 From: brianc Date: Tue, 19 Oct 2010 22:55:26 -0500 Subject: [PATCH] start to handle other auth messages --- lib/parser.js | 10 ++++++++-- test/unit/test-buffers.js | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/parser.js b/lib/parser.js index 46a0f444..f94032ee 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -54,10 +54,16 @@ p.parseMessage = function() { p.parseR = function(msg) { if(msg.length == 8) { - this.offset += 4; + msg.code = this.parseInt32(); + } + if(msg.code == 0) { return msg; } - throw new Error("Unknown authenticatinOk message type"); + if(msg.code == 3) { + msg.name = 'authenticationCleartextPassword'; + return msg; + } + throw new Error("Unknown authenticatinOk message type" + sys.inspect(msg)); }; p.parseS = function(msg) { diff --git a/test/unit/test-buffers.js b/test/unit/test-buffers.js index bf9b493d..e7b6c7f4 100644 --- a/test/unit/test-buffers.js +++ b/test/unit/test-buffers.js @@ -9,7 +9,7 @@ buffers.readyForQuery = function() { buffers.authenticationOk = function() { return new BufferList() - .addInt32(8) + .addInt32(0) .join(true, 'R'); };