(I already do fbStrategy.passReqToCallback = true
) I am riffing off
https://scotch.io/tutorials/easy-node-authentication-linking-all-accounts-together but want to use this social authentication service for multiple apps, ex: the one that controls the heating system, the one that turns on the sprinklers etc.
Basically if one of these apps checks with the server and doesn't have a correct token it get redirected to this social authentication service (social-auth). When the user presses on of the social login buttons it grabs the parameter of what app its arriving from and adds it as a parameter for /auth/facebook/:appid
// send to facebook to do the authentication
app.get('/auth/facebook/:appId', function(req,res,next){
passport.authenticate(
'facebook', { scope : 'email' }
)(req,res,next);
});
req
of req,res,next
is the serialized user record. At this point social-auth doesn't know who the user is.
fbStrategy.passReqToCallback = true;
passport.use(new FacebookStrategy(fbStrategy,
function(req, token, refreshToken, profile, done) {
var email = (profile.emails[0].value || '').toLowerCase()
process.nextTick(function() {...
Once authorization is complete I want to redirect back to the calling app and I need the :appId
param to ride along so I can go back to the right site.
Now generally it would work if I just made a variable like currentAppId
accessible to the various social stategies but If you happened to have multiple people authenticating at the same time then you conceivably have a user return to the wrong app, or some other users app. That's why I need appId
to travel as param to passport.authenticate
. Where should I be looking to figure out how. Could I wrap passport.authenticate
or otherwise modify things?