Don't attempt logging in on a PREAUTH connection

Node-imap already correctly recorded state for PREAUTH connections,
but attempted to login anyway, which results in a timeout, as it waits
for the connection to get into a state it can never reach.
fork
Andreas Fuchs 12 years ago
parent 867d6dfc4a
commit 86248a66aa

@ -145,25 +145,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