<div id="services" class="services">
<div id="services-top">
<h2>Services</h2>
</div>
<div id="services-content">
<div id="services-content-left">
<img id="services-content-right-img" class="img-circle" src="http://i.imgur.com/vN5m4vK.jpg" alt="empty">
<h3>STUFF</h3>
</div>
</div>
</div>
如果用户登录,他将重定向到example.com/his_name,但我得到了example.com/undefined。当我做console.log(req.user)时,它有价值。为什么呢?
答案 0 :(得分:0)
尝试将req.user
存储在如下变量中:
router.get('/', function(req, res, next) {
var currentUser = req.user;
if(currentUser) // this has value
res.redirect('/'+currentUser);
});