Skip to content

Commit

Permalink
add additional checks for xoauth2 handling
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Jul 25, 2013
1 parent b4132da commit 59ca339
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/client.js
Expand Up @@ -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{
Expand All @@ -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;
Expand Down

0 comments on commit 59ca339

Please sign in to comment.