I have a node.js code that uses passport openId connect strategy for authentication. It redirects back to original URL after authentication, however, if I submit a form with POST while session is expired, then it doesn't redirect back to original URL as a POST operation but changes it to GET request.
I want to know, is there any possible way, where I can store request type and after authentication it does same operation.
my app.js code looks like this:
app.get('/login', passport.authenticate('openidconnect', {}));
function ensureAuthenticated(req, res, next) {
if (!req.isAuthenticated()) {
req.session.originalUrl = req.originalUrl;
res.redirect('/login');
} else {
return next();
}
}
app.get('/auth/sso/callback',function(req, res, next) {
var redirect_url = req.session.originalUrl;
passport.authenticate('openidconnect', {
successRedirect: redirect_url,
failureRedirect: '/failure',
})(req,res,next);
});
PS: Authentication and other general redirects work fine.. the problem is with POST form submission only.