diff --git a/lib/imap.js b/lib/imap.js index fd47492..9e64af8 100644 --- a/lib/imap.js +++ b/lib/imap.js @@ -98,8 +98,8 @@ function ImapConnection(options) { this.delimiter = undefined; this.namespaces = { personal: [], other: [], shared: [] }; this.capabilities = []; - this.isConnected = false; - this.isAuthenticated = false; + this.connected = false; + this.authenticated = false; } inherits(ImapConnection, EventEmitter); @@ -121,6 +121,7 @@ ImapConnection.prototype.connect = function(loginCb) { // TODO: support STARTTLS state.conn.cleartext = utils.setSecure(state.conn); state.conn.on('secure', function() { + state.connected = true; self.debug&&self.debug('[connection] Secure connection made.'); }); } else @@ -128,16 +129,16 @@ ImapConnection.prototype.connect = function(loginCb) { state.conn.on('connect', function() { clearTimeout(state.tmrConn); - state.isConnected = true; - state.isAuthenticated = false; + state.connected = true; + state.authenticated = false; self.debug&&self.debug('[connection] Connected to host.'); state.conn.cleartext.write(''); state.status = STATES.NOAUTH; }); state.conn.on('end', function() { - state.isConnected = false; - state.isAuthenticated = false; + state.connected = false; + state.authenticated = false; self.debug&&self.debug('[connection] FIN packet received. Disconnecting...'); self.emit('end'); }); @@ -155,8 +156,8 @@ ImapConnection.prototype.connect = function(loginCb) { state.conn.on('close', function(had_error) { self._reset(); requests = state.requests; - state.isConnected = false; - state.isAuthenticated = false; + state.connected = false; + state.authenticated = false; self.debug&&self.debug('[connection] Connection closed.'); self.emit('close', had_error); }); @@ -523,7 +524,7 @@ ImapConnection.prototype.connect = function(loginCb) { break; case 'PREAUTH': state.status = STATES.AUTH; - state.isAuthenticated = true; + state.authenticated = true; if (state.numCapRecvs === 0) state.numCapRecvs = 1; break; @@ -671,7 +672,7 @@ ImapConnection.prototype.connect = function(loginCb) { }; ImapConnection.prototype.isAuthenticated = function() { - return this._state.status >= STATES.AUTH; + return this.authenticated; }; ImapConnection.prototype.logout = function(cb) { @@ -1347,7 +1348,7 @@ ImapConnection.prototype._login = function(cb) { fnReturn = function(err) { if (!err) { self._state.status = STATES.AUTH; - self._state.isAuthenticated = true; + self._state.authenticated = true; if (self._state.numCapRecvs !== 2) { // fetch post-auth server capabilities if they were not // automatically provided after login