(I already do fbStrategy.passReqToCallback = true ) I am a rifle https://scotch.io/tutorials/easy-node-authentication-linking-all-accounts-together , but you want to use this social authentication service for several applications, for example: one that controls the heating system, one that includes sprinklers, etc.
Basically, if one of these applications checks with the server and does not have the correct token, it is redirected to this social authentication service (social-auth). When the user presses the social login buttons, he grabs the parameter of which application the application comes to 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 a serialized user record. At the moment, social-auth does not 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 application, and I need a parameter :appId to drive it so that I can return to the correct site.
Now, as a rule, this will work if I just made a variable of type currentAppId available for various social strategies, but if you had several authenticated users at the same time, then you may be returning to the wrong application, or some other users. This is why I need appId navigate as a parameter in passport.authenticate . Where should I look for how to do this. Can I wrap passport.authenticate or change other things?