Commit 29f8e077 by Jose Carlos López

Fix close connection to imap server

parent 7634621c
Showing with 6 additions and 3 deletions
...@@ -62,16 +62,20 @@ Strategy.prototype.authenticate = function(req, options) { ...@@ -62,16 +62,20 @@ Strategy.prototype.authenticate = function(req, options) {
var user = self._success_callback(this, imap); var user = self._success_callback(this, imap);
if (!user.id) { if (!user.id) {
console.log("Success fallback must return an object with id parameter!"); console.log("Success fallback must return an object with id parameter!");
imap.end();
return self.fail("Success fallback must return an object with id parameter!"); return self.fail("Success fallback must return an object with id parameter!");
} }
self.success(user, "success"); self.success(user, "success");
imap.end();
} else { } else {
console.log("Success fallback is required to generate the user!"); console.log("Success fallback is required to generate the user!");
imap.end();
return self.fail("Success fallback is required to generate the user!"); return self.fail("Success fallback is required to generate the user!");
} }
}); });
imap.connect(); imap.connect();
imap.once('error', function(err) { imap.once('error', function(err) {
imap.end();
return self.fail("Invalid credantials"); return self.fail("Invalid credantials");
}); });
} }
...@@ -79,5 +83,5 @@ Strategy.prototype.authenticate = function(req, options) { ...@@ -79,5 +83,5 @@ Strategy.prototype.authenticate = function(req, options) {
/** /**
* Expose `Strategy`. * Expose `Strategy`.
*/ */
module.exports = Strategy; module.exports = Strategy;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment