summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAcid Chicken (硫酸鶏) <root@acid-chicken.com>2019-02-03 22:21:55 +0900
committerGitHub <noreply@github.com>2019-02-03 22:21:55 +0900
commitce576dea8fe3356e919723f71d7ea09d378f3bea (patch)
tree39b443c01ccbbebb8e49513bf304cbcd1d15767a /src
parentCreate new type definition for 'escape-regexp' (#4058) (diff)
downloadsharkey-ce576dea8fe3356e919723f71d7ea09d378f3bea.tar.gz
sharkey-ce576dea8fe3356e919723f71d7ea09d378f3bea.tar.bz2
sharkey-ce576dea8fe3356e919723f71d7ea09d378f3bea.zip
Create type definition for 'recaptcha-promise' (#4068)
Diffstat (limited to 'src')
-rw-r--r--src/@types/recaptcha-promise.d.ts16
-rw-r--r--src/server/api/private/signup.ts3
2 files changed, 17 insertions, 2 deletions
diff --git a/src/@types/recaptcha-promise.d.ts b/src/@types/recaptcha-promise.d.ts
new file mode 100644
index 0000000000..cfbd5eebf2
--- /dev/null
+++ b/src/@types/recaptcha-promise.d.ts
@@ -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;
+}
diff --git a/src/server/api/private/signup.ts b/src/server/api/private/signup.ts
index b89629bcd1..6318eabdb8 100644
--- a/src/server/api/private/signup.ts
+++ b/src/server/api/private/signup.ts
@@ -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) {