mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
recaptcha: add friendy hint
This commit is contained in:
1 parent
87d8dce528
commit
f236af555b
3 files changed
+5
-3
No files matched your search
@@ -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) => {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
captcha fail: 您没有通过 Recaptcha 验证。
|
||||
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user