1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-11-29 07:18:52 +09:00

Create type definition for 'recaptcha-promise' (#4068)

This commit is contained in:
Acid Chicken (硫酸鶏) 2019-02-03 22:21:55 +09:00 committed by GitHub
parent ceda3dd72a
commit ce576dea8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

16
src/@types/recaptcha-promise.d.ts vendored Normal file
View File

@ -0,0 +1,16 @@
declare module 'recaptcha-promise' {
interface IVerifyOptions {
secret_key?: string;
}
interface IVerify {
(response: string, remoteAddress?: string): Promise<boolean>;
init(options: IVerifyOptions): IVerify;
}
namespace recaptchaPromise {} // Hack
const verify: IVerify;
export = verify;
}

View File

@ -8,14 +8,13 @@ import Meta from '../../../models/meta';
import RegistrationTicket from '../../../models/registration-tickets';
import usersChart from '../../../chart/users';
import fetchMeta from '../../../misc/fetch-meta';
import * as recaptcha from 'recaptcha-promise';
export default async (ctx: Koa.BaseContext) => {
const body = ctx.request.body as any;
const instance = await fetchMeta();
const recaptcha = require('recaptcha-promise');
// Verify recaptcha
// ただしテスト時はこの機構は障害となるため無効にする
if (process.env.NODE_ENV !== 'test' && instance.enableRecaptcha) {