recaptcha: init support

This commit is contained in:
undefined committed 2021-03-30 23:47:10 +08:00
1 parent f58db3eeb2
commit 8d3dc160a8
11 files changed
+80 -8

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.20.49",
"version": "2.20.50",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",
+1 -1
View File
@@ -57,7 +57,7 @@ class UserLogoutHandler extends Handler {
}
}
class UserRegisterHandler extends Handler {
export class UserRegisterHandler extends Handler {
async get() {
this.response.template = 'user_register.html';
}
+1 -1
View File
@@ -231,7 +231,7 @@ export const PRIV = {
PRIV_REJUDGE: 1 << 13,
PRIV_VIEW_USER_SECRET: 1 << 14,
PRIV_VIEW_JUDGE_STATISTICS: 1 << 15,
PRIV_UNLIMITED_RATE: 1 << 22,
PRIV_UNLIMITED_ACCESS: 1 << 22,
PRIV_ALL: -1,
PRIV_DEFAULT: 0,
+6 -1
View File
@@ -12,6 +12,7 @@ import type {
import type { DomainDoc } from '../loader';
import type { DocType } from '../model/document';
import type { ProblemSolutionHandler } from '../handler/problem';
import type { UserRegisterHandler } from '../handler/user';
const _hooks: Record<keyof any, Array<(...args: any[]) => any>> = {};
const logger = new Logger('bus', true);
@@ -23,7 +24,7 @@ function isBailed(value: any) {
export type Disposable = () => void;
export type VoidReturn = Promise<any> | any;
export interface EventMap {
export interface EventMap extends Record<string, any> {
'app/started': () => void
'app/load/lib': () => VoidReturn
'app/load/locale': () => VoidReturn
@@ -63,6 +64,10 @@ export interface EventMap {
'handler/create': (thisArg: Handler) => VoidReturn
'handler/init': (thisArg: Handler) => VoidReturn
'handler/before-prepare/UserRegister': (thisArg: UserRegisterHandler) => VoidReturn
'handler/before/UserRegister': (thisArg: UserRegisterHandler) => VoidReturn
'handler/after/UserRegister': (thisArg: UserRegisterHandler) => VoidReturn
'handler/finish/UserRegister': (thisArg: UserRegisterHandler) => VoidReturn
'handler/solution/get': (thisArg: ProblemSolutionHandler) => VoidReturn
'discussion/before-add': (
+7 -4
View File
@@ -274,7 +274,7 @@ export class HandlerCommon {
extraTitleContent?: string;
async limitRate(op: string, periodSecs: number, maxOperations: number) {
if (this.user && this.user.hasPriv(PRIV.PRIV_UNLIMITED_RATE)) return;
if (this.user && this.user.hasPriv(PRIV.PRIV_UNLIMITED_ACCESS)) return;
await opcount.inc(op, this.request.ip, periodSecs, maxOperations);
}
@@ -352,6 +352,7 @@ export class Handler extends HandlerCommon {
ctx: Koa.Context;
request: {
method: string,
host: string,
hostname: string,
ip: string,
@@ -384,6 +385,7 @@ export class Handler extends HandlerCommon {
super();
this.ctx = ctx;
this.request = {
method: ctx.request.method.toLowerCase(),
host: ctx.request.host,
hostname: ctx.request.hostname,
ip: ctx.request.ip,
@@ -634,15 +636,16 @@ async function handle(ctx, HandlerClass, checker) {
}
await bus.serial('handler/init', h);
await bus.serial(`handler/before-prepare/${HandlerClass.name.replace(/Handler$/, '')}`, h);
if (h._prepare) await h._prepare(args);
if (h.prepare) await h.prepare(args);
await bus.serial(`handler/before/${HandlerClass.name.replace(/Handler$/, '')}`, h);
if (h[method]) await h[method](args);
if (operation) await h[`post${operation}`](args);
await bus.serial(`handler/after/${HandlerClass.name.replace(/Handler$/, '')}`, h);
if (h.cleanup) await h.cleanup(args);
if (h.finish) await h.finish(args);
await bus.serial(`handler/finish/${HandlerClass.name.replace(/Handler$/, '')}`, h);
} catch (e) {
try {
await h.onerror(e);
+2
View File
@@ -231,6 +231,7 @@ const scripts: UpgradeScript[] = [
const _FRESH_INSTALL_IGNORE = 1;
await db.collection('domain.user').deleteMany({ uid: null });
await db.collection('domain.user').deleteMany({ uid: 0 });
return true;
},
async function _15_16() {
const _FRESH_INSTALL_IGNORE = 1;
@@ -242,6 +243,7 @@ const scripts: UpgradeScript[] = [
if (JSON.stringify(af) !== JSON.stringify(pdoc.additional_file)) $set.additional_file = af;
if (Object.keys($set).length) await problem.edit(pdoc.domainId, pdoc.docId, $set);
});
return true;
},
];