我的认证系统返回未定义
My authentication system is returning undefined
我有一个使用护照的身份验证系统,我不知道为什么,但它返回'未定义'有谁能帮我一下,下面是我的代码:
app.js
passport.use(new LocalStrategy(function (username, password, done) {
Person.findOne({ 'account.username' : username }, function (err, person) {
if (err) {
return done(err);
}
if (!profile) {
return done(null, false, { message: 'Invalid username or password' });
}
// My self defined function that encrypts the password
var encryptedPassword = myFunc.encrypt(password);
if (person.account.password !== encryptedPassword) {
return done(null, false, { message: 'Invalid username or password' });
} else {
return done(null, profile);
}
});
}));
person.js
//POST: /login
app.post('/login', passport.authenticate('local', {failureRedirect: '/login',
failureFlash: true}),
function (req, res) {
console.log(req.profile);
res.redirect('/home');
}
);
//GET: /home
app.get('/home', function (req, res) {
console.log(req.profile); // Returns Undefined
});
当我渲染一个有请求的页面时也会发生这种情况。配置变量。
使用请求。用户而不是 req.profile
相关文章:
- 这.SOMETHING 总是返回未定义的 - extjs
- React+Meteor:this.ops返回未定义
- "日期“;AJAX请求返回的类型值未定义
- Regex提取URL返回数组的一部分;未定义”;
- 换行符拆分返回“”;未定义”;
- 解析-为什么user.getSessionToken()返回未定义的结果
- Javascript函数返回未定义
- JavaScript-获取数据属性的值返回未定义的值
- .val()返回未定义的.text返回随机代码
- 为什么innerHTML返回“未定义”
- "这个“;正在返回未定义的
- 函数jquery的未定义返回
- 为什么typeof的数组的数组的未定义值返回为“0”;未定义的“;我的条件不认为是真的
- winJS 从函数未定义返回 var
- $.get jquery 中的未定义返回
- Javascript 函数未定义返回
- 数据 ID 一直未定义返回
- 函数调用Javascritpt的未定义返回值
- 在函数中提示未定义返回.(问题)范围
- JSON字符串的未定义返回