首页 > 为什么路由登录页使用了PASSPORT中间件就不用重定向到用户页呢?

为什么路由登录页使用了PASSPORT中间件就不用重定向到用户页呢?

.post(passport.authenticate('local'), function (req, res, next) {
    // access the authenticate username and password.
    if (!req.user.active) { // have not been active.
        req.logout();   // delete req.user & clear login session
        res.status(400);
        return res.send('Unactived');
    }
    res.end();
});

  1. 你的路由地址貌似没写

  2. end 方法是结束当前的请求并返回相应数据,也就是说你当前的地址是啥就是啥,你说的重定向可以试试这个方法redirect


res.end()就是把response进程结束了吧,如果要重定向用res.redirect()。

【热门文章】
【热门文章】