twikoo-func 1.7.20 → 1.7.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/utils/index.js +4 -2
package/package.json
CHANGED
package/utils/index.js
CHANGED
|
@@ -99,7 +99,7 @@ const fn = {
|
|
|
99
99
|
ruser: fn.ruser(comment.pid, comments),
|
|
100
100
|
top: comment.top,
|
|
101
101
|
isSpam: comment.isSpam,
|
|
102
|
-
isOwner: comment.uid === uid,
|
|
102
|
+
isOwner: Boolean(uid && comment.uid === uid),
|
|
103
103
|
created: comment.created,
|
|
104
104
|
updated: comment.updated
|
|
105
105
|
}
|
|
@@ -474,7 +474,9 @@ const fn = {
|
|
|
474
474
|
if (!comment) {
|
|
475
475
|
throw new Error('评论不存在')
|
|
476
476
|
}
|
|
477
|
-
|
|
477
|
+
// 无 token 的请求不具备任何归属权,必须直接拒绝,
|
|
478
|
+
// 防止 comment.uid 与 uid 同时为 undefined 时误判为本人
|
|
479
|
+
if (!uid || comment.uid !== uid) {
|
|
478
480
|
throw new Error('只能删除自己的评论')
|
|
479
481
|
}
|
|
480
482
|
return comment
|