【发布时间】:2018-09-15 03:56:14
【问题描述】:
成功登录后,我在Node express server 中为用户提供了 60 分钟的 Authenticated 会话。如果我react app 中的用户想要获取儿童列表,我必须检查 Authenticated 并且在这里我有问题,我做 axios 请求 get 并在我的文件中 app.js(node) 我做:
app.get('/childrenList', isUserLoggedIn, function(req, res, next){
children.getChildrenList(req, res, next);
});
我的函数是UserLoggedIn
function isUserLoggedIn(req, res, next) {
if (!req.session.user_id || typeof(req.session.user_id)==='undefined') {
res.redirect('/login');
}
else{
next();
}
}
我的 redux/actions 函数
export function childrenList(objSql,type){
return {
type: type,
payload: new Promise((resolve, reject)=>{
axios.get('/childrenList', objSql,{
})
.then(function(response) {
resolve(response);
});
})
}
}
如果用户刷新页面(重定向到'/login'),但如果用户在会话过期节点后单击“获取孩子”按钮不会重定向到页面'/login',Eveythign 工作正常。在session expired 之后如何重定向?
【问题讨论】: