diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2022-05-15 16:47:14 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2022-05-15 16:47:14 +0900 |
| commit | 02a43a310f6ad0cc9e9beccc26e51ab5b339e15f (patch) | |
| tree | 8f32004af5864cb377242d51b77d563af4f7e53a | |
| parent | feat(dev): okteto integration (diff) | |
| download | misskey-02a43a310f6ad0cc9e9beccc26e51ab5b339e15f.tar.gz misskey-02a43a310f6ad0cc9e9beccc26e51ab5b339e15f.tar.bz2 misskey-02a43a310f6ad0cc9e9beccc26e51ab5b339e15f.zip | |
CAPTCHA求めるのは2fa認証が無効になっているときだけにした
2faのトークンは期限付きだから、CAPTCHA解いてる間に期限切れになる
| -rw-r--r-- | packages/backend/src/server/api/private/signin.ts | 24 | ||||
| -rw-r--r-- | packages/client/src/components/signin.vue | 4 |
2 files changed, 14 insertions, 14 deletions
diff --git a/packages/backend/src/server/api/private/signin.ts b/packages/backend/src/server/api/private/signin.ts index e8b222a4d5..0024b8ce3e 100644 --- a/packages/backend/src/server/api/private/signin.ts +++ b/packages/backend/src/server/api/private/signin.ts @@ -20,18 +20,6 @@ export default async (ctx: Koa.Context) => { const instance = await fetchMeta(true); - if (instance.enableHcaptcha && instance.hcaptchaSecretKey) { - await verifyHcaptcha(instance.hcaptchaSecretKey, body['hcaptcha-response']).catch(e => { - ctx.throw(400, e); - }); - } - - if (instance.enableRecaptcha && instance.recaptchaSecretKey) { - await verifyRecaptcha(instance.recaptchaSecretKey, body['g-recaptcha-response']).catch(e => { - ctx.throw(400, e); - }); - } - const username = body['username']; const password = body['password']; const token = body['token']; @@ -96,6 +84,18 @@ export default async (ctx: Koa.Context) => { } if (!profile.twoFactorEnabled) { + if (instance.enableHcaptcha && instance.hcaptchaSecretKey) { + await verifyHcaptcha(instance.hcaptchaSecretKey, body['hcaptcha-response']).catch(e => { + ctx.throw(400, e); + }); + } + + if (instance.enableRecaptcha && instance.recaptchaSecretKey) { + await verifyRecaptcha(instance.recaptchaSecretKey, body['g-recaptcha-response']).catch(e => { + ctx.throw(400, e); + }); + } + if (same) { signin(ctx, user); return; diff --git a/packages/client/src/components/signin.vue b/packages/client/src/components/signin.vue index 4f88e1829c..d140e143d3 100644 --- a/packages/client/src/components/signin.vue +++ b/packages/client/src/components/signin.vue @@ -11,6 +11,8 @@ <template #prefix><i class="fas fa-lock"></i></template> <template #caption><button class="_textButton" type="button" @click="resetPassword">{{ $ts.forgotPassword }}</button></template> </MkInput> + <MkCaptcha v-if="meta.enableHcaptcha" ref="hcaptcha" v-model="hCaptchaResponse" class="_formBlock captcha" provider="hcaptcha" :sitekey="meta.hcaptchaSiteKey"/> + <MkCaptcha v-if="meta.enableRecaptcha" ref="recaptcha" v-model="reCaptchaResponse" class="_formBlock captcha" provider="recaptcha" :sitekey="meta.recaptchaSiteKey"/> <MkButton class="_formBlock" type="submit" primary :disabled="signing" style="margin: 0 auto;">{{ signing ? $ts.loggingIn : $ts.login }}</MkButton> </div> <div v-if="totpLogin" class="2fa-signin" :class="{ securityKeys: user && user.securityKeys }"> @@ -33,8 +35,6 @@ <template #label>{{ $ts.token }}</template> <template #prefix><i class="fas fa-gavel"></i></template> </MkInput> - <MkCaptcha v-if="meta.enableHcaptcha" ref="hcaptcha" v-model="hCaptchaResponse" class="_formBlock captcha" provider="hcaptcha" :sitekey="meta.hcaptchaSiteKey"/> - <MkCaptcha v-if="meta.enableRecaptcha" ref="recaptcha" v-model="reCaptchaResponse" class="_formBlock captcha" provider="recaptcha" :sitekey="meta.recaptchaSiteKey"/> <MkButton type="submit" :disabled="signing" primary style="margin: 0 auto;">{{ signing ? $ts.loggingIn : $ts.login }}</MkButton> </div> </div> |