环境:
win7 nodejs express
按照文档: https://leancloud.cn/docs/leanengine_webhosting_guide-node.html#用户状态管理1
当登录成功后调用 req.saveCurrentUser(user),就能保存登录用户的session。
现在报错:res.saveCurrentUser is not a function
我的代码:
step1:
app.js文件中: app.use(AV.Cloud.CookieSession({ secret: 'xxxxx', maxAge: 3600000, fetchUser: true }));
step2:登录接口
app.post('/webLogin', function(req, res) {
AV.User.logIn(req.body.username, req.body.password).then(function(user) {
res.saveCurrentUser(user);
res.redirect('/index');
}, function(error) {
res.redirect('/login');
});
})
错误如下:
也看到有相同问题的帖子 https://forum.leancloud.cn/t/savecurrentuser/12965/3
没看到怎么解决的。希望能帮助一下。
补充:通过 不用 req.saveCurrentUser ,通过AV.User.current()是能取到登录用户的值的,但是在较短时间内(一两个小时的样子)会莫名奇妙的为null,即AV.Cloud.CookieSession中的 过期时间根本就没有起效果。现在就想看文档说的req.currentUser是否真的不会过期。
-
创建时间
17年7月13日
-
最后回复
17年7月13日
-
2
回复
-
1.3K
浏览
-
2
用户
-
2
链接