Commit 73ba7c6a by GeekTantra

Added Success Callback to update user data when authenticated

parent e9bd14a4
Showing with 9 additions and 4 deletions
...@@ -44,6 +44,7 @@ Strategy.prototype.authenticate = function(req, options) { ...@@ -44,6 +44,7 @@ Strategy.prototype.authenticate = function(req, options) {
this._host = options.hostName || 'imap.gmail.com'; this._host = options.hostName || 'imap.gmail.com';
this._port = options.port || 993; this._port = options.port || 993;
this._tls = options.tls || true; this._tls = options.tls || true;
this._success_callback = options.success_callback || null;
if (!this._username || !this._password) { if (!this._username || !this._password) {
return this.fail(new BadRequestError(options.badRequestMessage || 'Missing credentials')); return this.fail(new BadRequestError(options.badRequestMessage || 'Missing credentials'));
} }
...@@ -56,11 +57,15 @@ Strategy.prototype.authenticate = function(req, options) { ...@@ -56,11 +57,15 @@ Strategy.prototype.authenticate = function(req, options) {
tls: this._tls, tls: this._tls,
tlsOptions: { rejectUnauthorized: false } tlsOptions: { rejectUnauthorized: false }
}); });
var user = {
username : imap.user,
id: 1
};
imap.once('ready', function(){ imap.once('ready', function(){
var microtime = process.hrtime();
var user = {
email: this._username,
id: (microtime[0] * 1000 + microtime[1] / 1000)*1000
};
if (typeof this._success_callback == "function") {
user = this._success_callback();
}
self.success(user, "success"); self.success(user, "success");
}); });
imap.connect(); imap.connect();
......
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