mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 17:46:28 +08:00
更换socket鉴权方式
This commit is contained in:
1 parent
8bb389eedd
commit
b9076cd5d3
7 files changed
+61
-59
No files matched your search
+19
-19
@@ -158,33 +158,33 @@ export function getNode(domainId: string, _id: string) {
|
||||
return document.get(domainId, document.TYPE_DISCUSSION_NODE, _id);
|
||||
}
|
||||
|
||||
export async function getVnode(domainId: string, ddoc: any, handler: any) {
|
||||
if (ddoc.parentType === document.TYPE_PROBLEM) {
|
||||
const pdoc = await problem.get(domainId, ddoc.parentId);
|
||||
export async function getVnode(domainId: string, type: number, id: string, handler: any) {
|
||||
if (type === document.TYPE_PROBLEM) {
|
||||
const pdoc = await problem.get(domainId, id);
|
||||
if (!pdoc) return null;
|
||||
if (pdoc.hidden && handler) handler.checkPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
||||
return { ...pdoc, type: ddoc.parentType, id: ddoc.parentId };
|
||||
return { ...pdoc, type, id };
|
||||
}
|
||||
if (ddoc.parentType === document.TYPE_CONTEST) {
|
||||
const tdoc = await contest.get(domainId, ddoc.parentId);
|
||||
return { ...tdoc, type: ddoc.parentType, id: ddoc.parentId };
|
||||
if (type === document.TYPE_CONTEST) {
|
||||
const tdoc = await contest.get(domainId, new ObjectID(id));
|
||||
return { ...tdoc, type, id };
|
||||
}
|
||||
if (ddoc.parentType === document.TYPE_DISCUSSION_NODE) {
|
||||
const ndoc = await getNode(domainId, ddoc.parentId);
|
||||
if (type === document.TYPE_DISCUSSION_NODE) {
|
||||
const ndoc = await getNode(domainId, id);
|
||||
return {
|
||||
...ndoc,
|
||||
title: ddoc.parentId,
|
||||
type: ddoc.parentType,
|
||||
id: ddoc.parentId,
|
||||
title: id,
|
||||
type,
|
||||
id,
|
||||
};
|
||||
}
|
||||
if (ddoc.parentType === document.TYPE_TRAINING) {
|
||||
const tdoc = await training.get(domainId, ddoc.parentId);
|
||||
return { ...tdoc, type: ddoc.parentType, id: ddoc.parentId };
|
||||
if (type === document.TYPE_TRAINING) {
|
||||
const tdoc = await training.get(domainId, id);
|
||||
return { ...tdoc, type, id };
|
||||
}
|
||||
if (ddoc.parentType === document.TYPE_HOMEWORK) {
|
||||
const tdoc = await contest.get(domainId, ddoc.parentId, document.TYPE_HOMEWORK);
|
||||
return { ...tdoc, type: ddoc.parentType, id: ddoc.parentId };
|
||||
if (type === document.TYPE_HOMEWORK) {
|
||||
const tdoc = await contest.get(domainId, new ObjectID(id), document.TYPE_HOMEWORK);
|
||||
return { ...tdoc, type, id };
|
||||
}
|
||||
return {
|
||||
title: 'Missing Node',
|
||||
@@ -201,7 +201,7 @@ export async function getListVnodes(domainId: string, ddocs: any, handler: any)
|
||||
const tasks = [];
|
||||
const res = {};
|
||||
async function task(ddoc) {
|
||||
const vnode = await getVnode(domainId, ddoc, handler);
|
||||
const vnode = await getVnode(domainId, ddoc.parentType, ddoc.parentId, handler);
|
||||
if (!res[ddoc.parentType]) res[ddoc.parentType] = {};
|
||||
res[ddoc.parentType][ddoc.parentId] = vnode;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import * as db from '../service/db';
|
||||
const coll = db.collection('token');
|
||||
|
||||
export const TYPE_SESSION = 0;
|
||||
export const TYPE_TOKEN = 1;
|
||||
export const TYPE_REGISTRATION = 2;
|
||||
export const TYPE_CHANGEMAIL = 3;
|
||||
export const TYPE_OAUTH = 4;
|
||||
@@ -90,7 +89,6 @@ global.Hydro.postInit.push(ensureIndexes);
|
||||
global.Hydro.model.token = {
|
||||
TYPE_SESSION,
|
||||
TYPE_CHANGEMAIL,
|
||||
TYPE_TOKEN,
|
||||
TYPE_OAUTH,
|
||||
TYPE_REGISTRATION,
|
||||
TYPE_LOSTPASS,
|
||||
|
||||
Reference in new issue
Block a user