Skip to content
This repository has been archived by the owner on May 22, 2019. It is now read-only.

Commit

Permalink
implement changes to NodeBB's authorization workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lots0logs committed Aug 20, 2016
1 parent ecf49f4 commit a8e3735
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions library.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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}));
Expand All @@ -85,6 +86,7 @@
if (err) {
return done(err);
}
authenticationController.onSuccessfulLogin(req, user.uid);
done(null, user);
});
})); // END passport.use(new Auth0Strategy( function() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit a8e3735

Please sign in to comment.