【发布时间】:2018-01-23 20:35:53
【问题描述】:
使用 mongoose 生成的 ObjectId 作为检查数据是否属于某个用户的一种方式是一种好习惯吗?
示例 sudo 代码:
数据库中的示例:
[ObjectId]: {
myStuff: 'foo'
}
检查授权示例:
if (jwt.bar.ObjectId === ObjectId) {
//then you can mod this data because it is yours
}
如果没有,推荐的解决方法是什么?
【问题讨论】:
标签: node.js express authentication mongoose jwt