recaptcha: add friendy hint

This commit is contained in:
undefined committed 2021-04-19 13:15:22 +08:00
1 parent 87d8dce528
commit f236af555b
3 files changed
+5 -3

No files matched your search

+3 -2
View File
@@ -1,10 +1,11 @@
import superagent from 'superagent';
import { ValidationError } from 'hydrooj/dist/error';
import { ValidationError, ForbiddenError } from 'hydrooj/dist/error';
import { PRIV } from 'hydrooj/dist/model/builtin';
import * as system from 'hydrooj/dist/model/system';
import * as bus from 'hydrooj/dist/service/bus';
bus.on('handler/before/UserRegister', async (thisArg) => {
if (!system.get('recaptcha.key')) return;
if (thisArg.request.method !== 'post') {
thisArg.UiContext.recaptchaKey = system.get('recaptcha.key');
return;
@@ -15,7 +16,7 @@ bus.on('handler/before/UserRegister', async (thisArg) => {
.field('secret', system.get('recaptcha.secret'))
.field('response', thisArg.args.captcha)
.field('remoteip', thisArg.request.ip);
if (!response.body.success) throw new ValidationError('captcha fail');
if (!response.body.success) throw new ForbiddenError('captcha fail');
});
bus.on('handler/after/UserRegister', async (thisArg) => {
+1
View File
@@ -0,0 +1 @@
captcha fail: 您没有通过 Recaptcha 验证。
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/recaptcha",
"version": "1.0.2",
"version": "1.0.3",
"description": "Google reCAPTCHA",
"main": "package.json",
"repository": "https://github.com/hydro-dev/Hydro.git",