You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I'm trying to read the application state in an error handler. It works fine inside a success handler, but inside the error handler req.authInfo is empty. But we may need the state there too to fully handle failure situations on a par with success situation.
Example code:
// Let's suppose our frontend app generates a token and passes it to OAuth flow.// After either success or failure the app wants to get it back and compare with// the initial value to check the final callback is legitimate and initiated by the app itself.app.get('/api/login/facebook',function(req,res,next){constoptions={state: {token: req.query.token}}passport.authenticate('facebook',options)(req,res,next)})app.get('/api/login/facebook/callback',passport.authenticate('facebook',{failWithError: true})function(req,res){constparams={result: 'success',token: req.authInfo.state.token,}res.redirect('/login?'+(newURLSearchParams(params)).toString())},function(err,req,res,next){constparams={result: 'error',message: err.message,token: req.authInfo.state.token,// <-- the problem}res.redirect('/login?'+(newURLSearchParams(params)).toString())})
The text was updated successfully, but these errors were encountered:
Hi! I'm trying to read the application state in an error handler. It works fine inside a success handler, but inside the error handler
req.authInfo
is empty. But we may need the state there too to fully handle failure situations on a par with success situation.Example code:
The text was updated successfully, but these errors were encountered: