From a8e3735ecfc384ebee51ccba22f69096bf34d6c7 Mon Sep 17 00:00:00 2001 From: Dustin Falgout Date: Fri, 19 Aug 2016 20:26:47 -0500 Subject: [PATCH] implement changes to NodeBB's authorization workflow --- library.js | 6 ++++-- package.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/library.js b/library.js index 0304e3f..6e3a1f4 100644 --- a/library.js +++ b/library.js @@ -37,6 +37,7 @@ passport = module.parent.require('passport'), request = module.parent.require('request'), Auth0Strategy = require('passport-auth0').Strategy, + authenticationController = module.parent.require('./controllers/authentication'), Auth0 = {}, constants; @@ -63,18 +64,18 @@ callbackURL: nconf.get('url') + '/auth/auth0/callback', passReqToCallback: true }, function(req, accessToken, refreshToken, params, profile, done) { - console.log(profile); if (req.hasOwnProperty('user') && req.user.hasOwnProperty('uid') && parseInt(req.user.uid) > 0) { // Save Auth0-specific information to the user User.setUserField(req.user.uid, 'auth0id', profile.id); db.setObjectField('auth0id:uid', profile.id, req.user.uid); + authenticationController.onSuccessfulLogin(req, req.user.uid); return done(null, req.user); } var email, email_obj = Array.isArray(profile.emails) && profile.emails.length ? profile.emails[0] : profile.emails; if (typeof email_obj === 'object' && email_obj.hasOwnProperty('value')) { - email = email_obj.value; + email = email_obj.value; } if (typeof email !== 'string') { console.log('AUTH0 ERROR - ENO-010: ' + JSON.stringify({user: req.user, profile: profile})); @@ -85,6 +86,7 @@ if (err) { return done(err); } + authenticationController.onSuccessfulLogin(req, user.uid); done(null, user); }); })); // END passport.use(new Auth0Strategy( function() { diff --git a/package.json b/package.json index 775a67b..41a0848 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodebb-plugin-sso-auth0", - "version": "1.0.12", + "version": "1.0.13", "description": "NodeBB Auth0 SSO", "main": "library.js", "repository": {