From 59ca3396203e813491d3f9941290370ede41d9d9 Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Thu, 25 Jul 2013 10:17:07 +0300 Subject: [PATCH] add additional checks for xoauth2 handling --- lib/client.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/client.js b/lib/client.js index c8fb7cb..3e9c21e 100644 --- a/lib/client.js +++ b/lib/client.js @@ -757,7 +757,7 @@ SMTPClient.prototype._actionAUTHComplete = function(str){ response.shift(); response = JSON.parse(new Buffer(response.join(" "), "base64").toString("utf-8")); - if((!this._xoauth2.reconnectCount || this._xoauth2.reconnectCount < 2) && ['400','401'].indexOf(response.status)>=0){ + if((!this._xoauth2.reconnectCount || this._xoauth2.reconnectCount < 200) && ['400','401'].indexOf(response.status)>=0){ this._xoauth2.reconnectCount = (this._xoauth2.reconnectCount || 0) + 1; this._currentAction = this._actionXOAUTHRetry; }else{ @@ -782,7 +782,15 @@ SMTPClient.prototype._actionAUTHComplete = function(str){ }; SMTPClient.prototype._actionXOAUTHRetry = function(str){ + + // ensure that something is listening unexpected responses + this._currentAction = this._actionIdle; + this._xoauth2.generateToken((function(err, token){ + if(this._destroyed){ + // Nothing to do here anymore, connection closed + return; + } if(err){ this._onError(err, "XOAUTH2Error"); return;