refactor
This commit is contained in:
parent
ca6a70e555
commit
9053b9635e
|
@ -12,25 +12,28 @@ export default async (ctx: Koa.Context) => {
|
||||||
|
|
||||||
// Verify *Captcha
|
// Verify *Captcha
|
||||||
// ただしテスト時はこの機構は障害となるため無効にする
|
// ただしテスト時はこの機構は障害となるため無効にする
|
||||||
if (process.env.NODE_ENV !== 'test' && instance.enableHcaptcha && instance.hcaptchaSecretKey) {
|
if (process.env.NODE_ENV !== 'test') {
|
||||||
const success = await verify(instance.hcaptchaSecretKey, body['hcaptcha-response']).then(
|
if (instance.enableHcaptcha && instance.hcaptchaSecretKey) {
|
||||||
({ success }) => success,
|
const success = await verify(instance.hcaptchaSecretKey, body['hcaptcha-response']).then(
|
||||||
() => false,
|
({ success }) => success,
|
||||||
);
|
() => false,
|
||||||
|
);
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
ctx.throw(400, 'hcaptcha-failed');
|
ctx.throw(400, 'hcaptcha-failed');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (process.env.NODE_ENV !== 'test' && instance.enableRecaptcha && instance.recaptchaSecretKey) {
|
|
||||||
recaptcha.init({
|
|
||||||
secret_key: instance.recaptchaSecretKey
|
|
||||||
});
|
|
||||||
|
|
||||||
const success = await recaptcha(body['g-recaptcha-response']);
|
if (instance.enableRecaptcha && instance.recaptchaSecretKey) {
|
||||||
|
recaptcha.init({
|
||||||
|
secret_key: instance.recaptchaSecretKey
|
||||||
|
});
|
||||||
|
|
||||||
if (!success) {
|
const success = await recaptcha(body['g-recaptcha-response']);
|
||||||
ctx.throw(400, 'recaptcha-failed');
|
|
||||||
|
if (!success) {
|
||||||
|
ctx.throw(400, 'recaptcha-failed');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue