mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: handle 2FA permission check
This commit is contained in:
1 parent
f68b8d54cf
commit
502ced8f27
4 files changed
+6
-1
No files matched your search
@@ -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",
|
||||
|
||||
@@ -94,6 +94,8 @@ export function rebuild() {
|
||||
}
|
||||
|
||||
class ApiHandler extends Handler {
|
||||
noCheckPermView = true;
|
||||
|
||||
query(q: string, variables: any) {
|
||||
return graphql({
|
||||
schema,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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]);
|
||||
|
||||
Reference in new issue
Block a user