Sunday, 16 April 2017

Including extra data into Passport middleware with Express

A user is coming to my web route from another application with a link that was generated in this form: /auth/steam/:id/:token, where :id and :token are not required for this Passport middleware. They are just parameters I want to keep track of.

When the user successfully authenticates, I want to have access to these values from the initial web request to /auth/steam/. My routes currently look like this:

this.app.get('/auth/steam/:id/:token', passport.authenticate('steam'), () => {

});

this.app.get('/auth/steam/return', passport.authenticate('steam', { failureRedirect: '/login' }), (req, res) => {
  // Would like access to id and token here

  res.render('index');
});

Is it possible to keep data along with the request into the return route, etc. where I noted I want to use the values? I was thinking of using a session but was hoping to avoid that.

Thanks!



via Kevin Murphy

No comments:

Post a Comment