Merge pull request #109 from antifuchs/fix-preauth-connections

Don't attempt logging in on a PREAUTH connection
fork
Brian White 12 years ago
commit d3a366bd84

@ -158,25 +158,32 @@ ImapConnection.prototype.connect = function(loginCb) {
});
state.conn.on('ready', function() {
// First get pre-auth capabilities, including server-supported auth
// mechanisms
var checkedNS = false;
var redo = function(err) {
if (err)
return loginCb(err);
// Next, get the list of available namespaces if supported (RFC2342)
if (!checkedNS && self._serverSupports('NAMESPACE')) {
// Re-enter this function after we've obtained the available
// namespaces
checkedNS = true;
return self._send('NAMESPACE', redo);
}
// Lastly, get the top-level mailbox hierarchy delimiter used by the
// server
self._send('LIST "" ""', loginCb);
};
// First, get the supported (pre-auth or otherwise) capabilities:
self._send('CAPABILITY', function() {
// Next, attempt to login
var checkedNS = false;
self._login(function redo(err) {
if (err)
return loginCb(err);
// Next, get the list of available namespaces if supported (RFC2342)
if (!checkedNS && self._serverSupports('NAMESPACE')) {
// Re-enter this function after we've obtained the available
// namespaces
checkedNS = true;
return self._send('NAMESPACE', redo);
}
// Lastly, get the top-level mailbox hierarchy delimiter used by the
// server
self._send('LIST "" ""', loginCb);
});
// No need to attempt the login sequence if we're on a PREAUTH
// connection.
if (state.status != STATES.AUTH) {
// First get pre-auth capabilities, including server-supported auth
// mechanisms
self._login(redo);
} else {
redo();
};
});
});

Loading…
Cancel
Save