添加PERM_NEVER & PRIV_NEVER

This commit is contained in:
undefined committed 2020-09-26 20:43:34 +08:00
1 parent 21c2bb95f0
commit e1cfe1cf4d
5 files changed
+7 -7

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.13.19",
"version": "2.13.20",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",
+1 -1
View File
@@ -242,7 +242,7 @@ class ContestProblemHandler extends ContestHandler {
this.response.template = 'problem_detail.html';
if (contest.isDone(this.tdoc)) {
if (!this.attended) throw new ContestNotAttendedError(this.tdoc.docId);
if (!contest.isOngoing(this.tdoc)) throw new ContestNotLiveError(this.tdoc.docId);
if (contest.isNotStarted(this.tdoc)) throw new ContestNotLiveError(this.tdoc.docId);
}
if (!this.tdoc.pids.map((s) => s.toString()).includes(this.pdoc.docId.toString())) {
throw new ProblemNotFoundError(pid, this.tdoc.docId);
+1 -1
View File
@@ -128,7 +128,7 @@ class HomeworkDetailProblemHandler extends HomeworkHandler {
const attended = this.tsdoc && this.tsdoc.attend === 1;
if (!contest.isDone(this.tdoc)) {
if (!attended) throw new HomeworkNotAttendedError(tid);
if (!contest.isOngoing(this.tdoc)) throw new HomeworkNotLiveError(tid);
if (contest.isNotStarted(this.tdoc)) throw new HomeworkNotLiveError(tid);
}
if (!this.tdoc.pids.includes(pid)) throw new ProblemNotFoundError(domainId, pid, tid);
const path = [
+3
View File
@@ -88,6 +88,8 @@ export const PERM = {
PERM_BASIC: 0n,
PERM_DEFAULT: 0n,
PERM_ADMIN: -1n,
PERM_NEVER: 1n << 59n,
};
export const Permission = (family: string, key: BigInt, desc: string) => ({ family, key, desc });
@@ -237,6 +239,7 @@ export const PRIV = {
PRIV_ALL: -1,
PRIV_DEFAULT: 0,
PRIV_NEVER: 1 << 20,
};
PRIV.PRIV_DEFAULT = PRIV.PRIV_USER_PROFILE
+1 -4
View File
@@ -158,14 +158,11 @@ export async function incUserInDomain(domainId: string, uid: number, field: stri
export async function getDictUserByDomainId(uid: number) {
const dudocs = await collUser.find({ uid }).toArray();
const ddocs = await coll.find({ owner: uid }).toArray();
const dudict = {};
for (const dudoc of dudocs) {
// eslint-disable-next-line no-await-in-loop
dudict[dudoc.domainId] = await get(dudoc.domainId);
}
for (const ddoc of ddocs) {
dudict[ddoc._id] = ddoc;
dudict[dudoc.domainId].role = dudoc.role;
}
return dudict;
}