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) {
var user = self._success_callback(this, imap);
if (!user.id) {
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!");
}
self.success(user, "success");
imap.end();
} else {
console.log("Success fallback is required to generate the user!");
imap.end();
return self.fail("Success fallback is required to generate the user!");
}
});
imap.connect();
imap.once('error', function(err) {
imap.end();
return self.fail("Invalid credantials");
});
}
......@@ -79,5 +83,5 @@ Strategy.prototype.authenticate = function(req, options) {
/**
* Expose `Strategy`.
*/
module.exports = Strategy;
\ No newline at end of file
*/
module.exports = Strategy;
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