我正在使用 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)