javascript - How to send post data on success redirect with passport?
问题描述
I am trying to post data through my login form. I am using passport to authenticate the users credentials. Typically to post data through a form I use:
app.post('/login_mrkt', (req,res) => {
console.log(req) //Contains post data from form
}
However as I want to authenticate the user I use the below code:
app.post('/login_mrkt', checkNotAuthenticated, passport.authenticate('local', {
successRedirect: '/dash',
failureRedirect: '/login',
failureFlash: true
}))
When the login is successful it redirects my user to /dash
get. However this does not contain the post data from the form:
app.get('/dash', checkAuthenticated, (req,res) => {
console.log(req) //This does not contain post data, but I want it to
})
How can I make it so I can retrieve the post data from my fomr in the /dash
get?
Edit
Here is my checkAuthenticated method as requested:
function checkAuthenticated(req, res, next) {
if (req.isAuthenticated()) {
return next()//can think of next() as go to the next function in the request call back function
}
res.redirect('/login')
}
解决方案
推荐阅读
- python - 有没有办法通过使用导入的 csv 中的字符串来生成列表名称?
- ios - IOS Webkit 跟踪被点击的 url 和 URL Scheme
- java - 为什么 Java 9 中不推荐使用 finalize() 方法?
- java - 为什么我的服务无法在 Android Pie 上运行
- ios - Obj-c - 对字典中的数组进行排序?
- php - 包裹在字符串中的 PHP WPML 字符串翻译
- sql - 结果数据集中的 SQL 案例表达式问题
- python - 使用 glob 时添加文件时间戳列的修改
- javascript - 如何在componentDidMount中存根异步操作以使用Jest进行react redux连接组件测试
- php - php - 如何使用通过 composer 安装的包