我正在使用Passport授權我的項目。成功驗證後,用戶被定向到「/home」。此時,請求具有用戶對象。但是,一旦我重定向,req.user.email是未定義的。 :'(無法獲取req.user的屬性
exports.test= function (req, res) {
console.log(req.user);
console.log(req.user.id);
console.log(req.user.email);
}
終端顯示:
ModelBase {
attributes:
{ id: 18,
first_name: 'test',
last_name: 'test',
email: '[email protected]',
password: '18fa9883b74578494b578048273e66d2edbf57b6',
active: 1,
created: Mon Oct 17 2016 08:15:58 GMT+0700 (SE Asia Standard Time),
modified: Thu Nov 17 2016 10:59:00 GMT+0700 (SE Asia Standard Time),
salt: '140996000870',
Balance: 0,
ExpireDate: Mon Apr 02 2018 00:00:00 GMT+0700 (SE Asia Standard Time),
used: 0,
donate: 1 },
_previousAttributes:
{ id: 18,
first_name: 'test',
last_name: 'test',
email: '[email protected]',
password: '18fa9883b74578494b578048273e66d2edbf57b6',
active: 1,
created: Mon Oct 17 2016 08:15:58 GMT+0700 (SE Asia Standard Time),
modified: Thu Nov 17 2016 10:59:00 GMT+0700 (SE Asia Standard Time),
salt: '140996000870',
Balance: 0,
ExpireDate: Mon Apr 02 2018 00:00:00 GMT+0700 (SE Asia Standard Time),
used: 0,
donate: 1 },
changed: {},
relations: {},
cid: 'c1',
id: 18,
_knex: null }
18
undefined
這是工作謝謝 – beginerdeveloper