小编And*_*ito的帖子

PassportJS 重命名“用户”对象

我正在使用 PassportJS 进行登录功能有没有办法更改请求中的“用户”对象名称?

默认情况下,这就是它现在的工作方式(req.user):

function (req, res, next) {
    if (!req.user) {
        req.flash('error', 'Please sign in to access this page.');
        res.redirect('/login');
    } else {
        next();
    }
}
Run Code Online (Sandbox Code Playgroud)

我想改用以下内容(req.candidate):

function (req, res, next) {
    if (!req.candidate) {
        req.flash('error', 'Please sign in to access this page.');
        res.redirect('/login');
    } else {
        next();
    }
}
Run Code Online (Sandbox Code Playgroud)

authentication mongodb node.js passport-local passport.js

4
推荐指数
1
解决办法
906
查看次数