我有这个密码:
user.findOne( { 'email' : email }, function( err, User )
{
if ( err )
{
return done(err);
}
if ( !User )
{
return done(null, false, { error : "User not found"});
}
if ( !User.hasOwnProperty('local') || !User.local.hasOwnProperty('password') )
{
console.log("here: " + User.hasOwnProperty('local')); // displays here: false
}
if ( !User.validPass(password) )
{
return done(null, false, { error : "Incorrect Password"});
}
return done(null, User);
});
由于该应用程序支持其他类型的身份验证,我有一个用户模型,其中包含名为local的嵌套对象
local : { password : "USERS_PASSWORD" }
因此,在登录期间,我想判断用户是否提供了密码,但我遇到了这个有趣的问题.
{ _id: 5569ac206afebed8d2d9e11e,
email: 'test@example.com',
phno: '1234567890',
gender: 'female',
dob: Wed May 20 2015 05:30:00 GMT+0530 (IST),
name: 'Test Account',
__v: 0,
local: { password: '$2a$07$gytktl7BsmhM8mkuh6JVc3Bs/my7Jz9D0KBcDuKh01S' } }
但是console.log("here: " + User.hasOwnProperty('local'));
张打印here: false
张
我哪里出错了?