移除权限节点,添加 get post route 修饰器

PERM_EDIT_DISCUSSION_REPLY_SELF_DISCUSSION
PERM_EDIT_DISCUSSION_REPLY
PERM_EDIT_PROBLEM_SOLUTION_REPLY
This commit is contained in:
undefined committed 2020-09-25 23:13:35 +08:00
1 parent 6dd7a4dcb8
commit 99b7d33157
8 files changed
+120 -63

No files matched your search

+5 -7
View File
@@ -1,6 +1,6 @@
import { ObjectID } from 'mongodb';
import { isSafeInteger } from 'lodash';
import { DiscussionNotFoundError, DocumentNotFoundError } from '../error';
import { DiscussionNotFoundError, DocumentNotFoundError, PermissionError } from '../error';
import {
Mdoc, Drdoc, Ddoc, Drrdoc,
} from '../interface';
@@ -242,11 +242,8 @@ class DiscussionDetailHandler extends DiscussionHandler {
@param('drid', Types.ObjectID)
@param('content', Types.String, isContent)
async postEditReply(domainId: string, drid: ObjectID, content: string) {
if (!(this.ddoc.owner === this.user._id
&& this.user.hasPerm(PERM.PERM_EDIT_DISCUSSION_REPLY_SELF_DISCUSSION))) {
if (this.drdoc.owner !== this.user._id) this.checkPerm(PERM.PERM_EDIT_DISCUSSION_REPLY);
else this.checkPerm(PERM.PERM_EDIT_DISCUSSION_REPLY_SELF);
}
this.checkPerm(PERM.PERM_EDIT_DISCUSSION_REPLY_SELF);
if (this.drdoc.owner !== this.user._id) throw new PermissionError(PERM.PERM_EDIT_DISCUSSION_REPLY_SELF);
await discussion.editReply(domainId, drid, content);
this.back();
}
@@ -267,7 +264,8 @@ class DiscussionDetailHandler extends DiscussionHandler {
@param('drrid', Types.ObjectID)
@param('content', Types.String, isContent)
async postEditTailReply(domainId: string, drid: ObjectID, drrid: ObjectID, content: string) {
if (this.drdoc.owner !== this.user._id) this.checkPerm(PERM.PERM_EDIT_DISCUSSION_REPLY);
this.checkPerm(PERM.PERM_EDIT_DISCUSSION_REPLY_SELF);
if (this.drdoc.owner !== this.user._id) throw new PermissionError(PERM.PERM_EDIT_DISCUSSION_REPLY_SELF);
await discussion.editTailReply(domainId, drid, drrid, content);
this.back();
}