mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
ui: fix assign text & core: allow owner get homework detail (#345)
This commit is contained in:
1 parent
de9426a7fc
commit
59f1b4e429
7 files changed
+8
-4
No files matched your search
@@ -83,7 +83,7 @@ export class ContestDetailHandler extends Handler {
|
||||
@param('page', Types.PositiveInt, true)
|
||||
async prepare(domainId: string, tid: ObjectID) {
|
||||
const tdoc = await contest.get(domainId, tid);
|
||||
if (tdoc.assign?.length) {
|
||||
if (tdoc.assign?.length && !this.user.own(tdoc)) {
|
||||
const groups = await user.listGroup(domainId, this.user._id);
|
||||
if (!Set.intersection(tdoc.assign, groups.map((i) => i.name)).size) {
|
||||
throw new ForbiddenError('You are not assigned.');
|
||||
|
||||
@@ -61,7 +61,7 @@ class DiscussionHandler extends Handler {
|
||||
// TODO(twd2): exclude problem/contest discussions?
|
||||
// TODO(iceboy): continuation based pagination.
|
||||
this.vnode = await discussion.getVnode(domainId, typeMapper[type], name, this.user._id);
|
||||
if (this.vnode.assign?.length) {
|
||||
if (this.vnode.assign?.length && !this.user.own(this.vnode)) {
|
||||
if (!Set.intersection(this.vnode.assign, this.user.group).size) {
|
||||
throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class HomeworkDetailHandler extends Handler {
|
||||
async prepare(domainId: string, tid: ObjectID) {
|
||||
const tdoc = await contest.get(domainId, tid);
|
||||
if (tdoc.rule !== 'homework') throw new ContestNotFoundError(domainId, tid);
|
||||
if (tdoc.assign?.length) {
|
||||
if (tdoc.assign?.length && !this.user.own(tdoc)) {
|
||||
if (!Set.intersection(tdoc.assign, this.user.group).size) {
|
||||
throw new ForbiddenError('You are not assigned.');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user