mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: add PERM_VIEW_RECORD (#753)
This commit is contained in:
1 parent
ae7563841f
commit
b7a331ec15
4 files changed
+19
-2
No files matched your search
@@ -54,6 +54,7 @@ class RecordListHandler extends ContestDetailBaseHandler {
|
|||||||
if (udoc) q.uid = udoc._id;
|
if (udoc) q.uid = udoc._id;
|
||||||
else invalid = true;
|
else invalid = true;
|
||||||
}
|
}
|
||||||
|
if (q.uid !== this.user._id) this.checkPerm(PERM.PERM_VIEW_RECORD);
|
||||||
if (tid) {
|
if (tid) {
|
||||||
tdoc = await contest.get(domainId, tid);
|
tdoc = await contest.get(domainId, tid);
|
||||||
this.tdoc = tdoc;
|
this.tdoc = tdoc;
|
||||||
@@ -136,6 +137,7 @@ class RecordDetailHandler extends ContestDetailBaseHandler {
|
|||||||
async prepare(domainId: string, rid: ObjectId) {
|
async prepare(domainId: string, rid: ObjectId) {
|
||||||
this.rdoc = await record.get(domainId, rid);
|
this.rdoc = await record.get(domainId, rid);
|
||||||
if (!this.rdoc) throw new RecordNotFoundError(rid);
|
if (!this.rdoc) throw new RecordNotFoundError(rid);
|
||||||
|
if (this.rdoc.uid !== this.user._id) this.checkPerm(PERM.PERM_VIEW_RECORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
async download() {
|
async download() {
|
||||||
@@ -288,6 +290,7 @@ class RecordMainConnectionHandler extends ConnectionHandler {
|
|||||||
else throw new UserNotFoundError(uidOrName);
|
else throw new UserNotFoundError(uidOrName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this.uid !== this.user._id) this.checkPerm(PERM.PERM_VIEW_RECORD);
|
||||||
if (pid) {
|
if (pid) {
|
||||||
const pdoc = await problem.get(domainId, pid);
|
const pdoc = await problem.get(domainId, pid);
|
||||||
if (pdoc) this.pid = pdoc.docId;
|
if (pdoc) this.pid = pdoc.docId;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export const PERM = {
|
|||||||
PERM_READ_PROBLEM_DATA: 1n << 10n,
|
PERM_READ_PROBLEM_DATA: 1n << 10n,
|
||||||
|
|
||||||
// Record
|
// Record
|
||||||
|
PERM_VIEW_RECORD: 1n << 70n,
|
||||||
PERM_READ_RECORD_CODE: 1n << 12n,
|
PERM_READ_RECORD_CODE: 1n << 12n,
|
||||||
PERM_READ_RECORD_CODE_ACCEPT: 1n << 66n,
|
PERM_READ_RECORD_CODE_ACCEPT: 1n << 66n,
|
||||||
PERM_REJUDGE_PROBLEM: 1n << 13n,
|
PERM_REJUDGE_PROBLEM: 1n << 13n,
|
||||||
@@ -114,6 +115,7 @@ export const PERMS = [
|
|||||||
Permission('perm_problem', PERM.PERM_VIEW_PROBLEM_HIDDEN, 'View hidden problems'),
|
Permission('perm_problem', PERM.PERM_VIEW_PROBLEM_HIDDEN, 'View hidden problems'),
|
||||||
Permission('perm_problem', PERM.PERM_SUBMIT_PROBLEM, 'Submit problem'),
|
Permission('perm_problem', PERM.PERM_SUBMIT_PROBLEM, 'Submit problem'),
|
||||||
Permission('perm_problem', PERM.PERM_READ_PROBLEM_DATA, 'Read data of problem'),
|
Permission('perm_problem', PERM.PERM_READ_PROBLEM_DATA, 'Read data of problem'),
|
||||||
|
Permission('perm_record', PERM.PERM_VIEW_RECORD, "View other's records"),
|
||||||
Permission('perm_record', PERM.PERM_READ_RECORD_CODE, 'Read all record codes'),
|
Permission('perm_record', PERM.PERM_READ_RECORD_CODE, 'Read all record codes'),
|
||||||
Permission('perm_record', PERM.PERM_READ_RECORD_CODE_ACCEPT, 'Read record codes after accept'),
|
Permission('perm_record', PERM.PERM_READ_RECORD_CODE_ACCEPT, 'Read record codes after accept'),
|
||||||
Permission('perm_record', PERM.PERM_REJUDGE_PROBLEM, 'Rejudge problems'),
|
Permission('perm_record', PERM.PERM_REJUDGE_PROBLEM, 'Rejudge problems'),
|
||||||
@@ -185,7 +187,8 @@ PERM.PERM_BASIC = PERM.PERM_VIEW
|
|||||||
| PERM.PERM_VIEW_HOMEWORK
|
| PERM.PERM_VIEW_HOMEWORK
|
||||||
| PERM.PERM_VIEW_HOMEWORK_SCOREBOARD
|
| PERM.PERM_VIEW_HOMEWORK_SCOREBOARD
|
||||||
| PERM.PERM_VIEW_TRAINING
|
| PERM.PERM_VIEW_TRAINING
|
||||||
| PERM.PERM_VIEW_RANKING;
|
| PERM.PERM_VIEW_RANKING
|
||||||
|
| PERM.PERM_VIEW_RECORD;
|
||||||
|
|
||||||
PERM.PERM_DEFAULT = PERM.PERM_VIEW
|
PERM.PERM_DEFAULT = PERM.PERM_VIEW
|
||||||
| PERM.PERM_VIEW_DISPLAYNAME
|
| PERM.PERM_VIEW_DISPLAYNAME
|
||||||
@@ -229,7 +232,8 @@ PERM.PERM_DEFAULT = PERM.PERM_VIEW
|
|||||||
| PERM.PERM_ATTEND_CONTEST
|
| PERM.PERM_ATTEND_CONTEST
|
||||||
| PERM.PERM_CREATE_TRAINING
|
| PERM.PERM_CREATE_TRAINING
|
||||||
| PERM.PERM_ATTEND_HOMEWORK
|
| PERM.PERM_ATTEND_HOMEWORK
|
||||||
| PERM.PERM_VIEW_RANKING;
|
| PERM.PERM_VIEW_RANKING
|
||||||
|
| PERM.PERM_VIEW_RECORD;
|
||||||
|
|
||||||
PERM.PERM_ADMIN = PERM.PERM_ALL;
|
PERM.PERM_ADMIN = PERM.PERM_ALL;
|
||||||
|
|
||||||
|
|||||||
@@ -630,6 +630,15 @@ const scripts: UpgradeScript[] = [
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
async function _85_86() {
|
||||||
|
return await iterateAllDomain(async (ddoc) => {
|
||||||
|
for (const role of Object.keys(ddoc.roles)) {
|
||||||
|
if (role === 'root') return;
|
||||||
|
ddoc.roles[role] = (BigInt(ddoc.roles[role]) | PERM.PERM_VIEW_RECORD).toString();
|
||||||
|
}
|
||||||
|
await domain.setRoles(ddoc._id, ddoc.roles);
|
||||||
|
});
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default scripts;
|
export default scripts;
|
||||||
@@ -46,6 +46,7 @@ __langname: 简体中文
|
|||||||
'Yes': 是
|
'Yes': 是
|
||||||
"Effects only when Difficulty is not 'Use algorithm calculated'.": 仅当难度不为“使用算法计算”时才起效。
|
"Effects only when Difficulty is not 'Use algorithm calculated'.": 仅当难度不为“使用算法计算”时才起效。
|
||||||
"Split by ', '.": 由“, ”或“,”分隔。
|
"Split by ', '.": 由“, ”或“,”分隔。
|
||||||
|
"View other's records": 查看他人的记录
|
||||||
"What's file?": 什么是文件?
|
"What's file?": 什么是文件?
|
||||||
(All Problems): (所有题目)
|
(All Problems): (所有题目)
|
||||||
(leave blank if none): (若不需要则留空)
|
(leave blank if none): (若不需要则留空)
|
||||||
|
|||||||
Reference in new issue
Block a user