core: handle 2FA permission check

This commit is contained in:
undefined committed 2022-10-18 19:38:23 +08:00
1 parent f68b8d54cf
commit 502ced8f27
4 files changed
+6 -1

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "4.2.1",
"version": "4.2.2",
"bin": "bin/hydrooj.js",
"main": "src/plugin-api",
"module": "src/plugin-api",
+2
View File
@@ -94,6 +94,8 @@ export function rebuild() {
}
class ApiHandler extends Handler {
noCheckPermView = true;
query(q: string, variables: any) {
return graphql({
schema,
+1
View File
@@ -44,6 +44,7 @@ registerValue('Contest', [
registerResolver(
'Query', 'contest(id: ObjectID!)', 'Contest',
async (arg, ctx) => {
ctx.checkPerm(PERM.PERM_VIEW);
arg.id = new ObjectID(arg.id);
ctx.tdoc = await contest.get(ctx.args.domainId, new ObjectID(arg.id));
if (!ctx.tdoc) throw new ContestNotFoundError(ctx.args.domainId, arg.id);
+2
View File
@@ -70,6 +70,7 @@ registerValue('Problem', [
registerResolver(
'Query', 'problem(id: Int, pid: String)', 'Problem',
async (arg, ctx) => {
ctx.checkPerm(PERM.PERM_VIEW);
const pdoc = await problem.get(ctx.args.domainId, arg.pid || arg.id);
if (!pdoc) return null;
if (pdoc.hidden) ctx.checkPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN);
@@ -83,6 +84,7 @@ registerResolver(
},
);
registerResolver('Query', 'problems(ids: [Int])', '[Problem]', async (arg, ctx) => {
ctx.checkPerm(PERM.PERM_VIEW);
const res = await problem.getList(ctx.args.domainId, arg.ids, ctx.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN) || ctx.user._id,
ctx.user.group, undefined, undefined, true);
return Object.keys(res).map((id) => res[+id]);