-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(frontend): Botプロテクションの設定変更時は実際に検証を通過しないと保存できないようにする #15151
Open
samunohito
wants to merge
16
commits into
misskey-dev:develop
Choose a base branch
from
samunohito:feat/15137-testing-captcha
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,593
−87
Open
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
41d5afb
feat(frontend): CAPTCHAの設定変更時は実際に検証を通過しないと保存できないようにする
samunohito cf57926
なしでも保存できるようにした
samunohito 12e75bb
fix CHANGELOG.md
samunohito 17b969e
Merge branch 'develop' into feat/15137-testing-captcha
samunohito 043530b
フォームが増殖するのを修正
samunohito f1c894a
add comment
samunohito 738d86f
add server-side verify
samunohito 3dade7a
fix ci
samunohito ce7f205
fix
samunohito ddbb0a4
fix
samunohito 968fa07
fix i18n
samunohito c5dab0f
add current.ts
samunohito 7fcf8af
fix text
samunohito 2b32b16
fix
samunohito 6e8b672
Merge branch 'develop' into feat/15137-testing-captcha
samunohito a060269
regenerate locales
samunohito File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,8 @@ SPDX-License-Identifier: AGPL-3.0-only | |
<template v-else-if="botProtectionForm.savedState.provider === 'turnstile'" #suffix>Turnstile</template> | ||
<template v-else-if="botProtectionForm.savedState.provider === 'testcaptcha'" #suffix>testCaptcha</template> | ||
<template v-else #suffix>{{ i18n.ts.none }} ({{ i18n.ts.notRecommended }})</template> | ||
<template v-if="botProtectionForm.modified.value" #footer> | ||
<MkFormFooter :form="botProtectionForm"/> | ||
<template #footer> | ||
<MkFormFooter :canSaving="canSaving" :form="botProtectionForm"/> | ||
</template> | ||
|
||
<div class="_gaps_m"> | ||
|
@@ -36,11 +36,18 @@ SPDX-License-Identifier: AGPL-3.0-only | |
<template #prefix><i class="ti ti-key"></i></template> | ||
<template #label>{{ i18n.ts.hcaptchaSecretKey }}</template> | ||
</MkInput> | ||
<FormSlot> | ||
<FormSlot v-if="botProtectionForm.state.hcaptchaSiteKey"> | ||
<template #label>{{ i18n.ts.preview }}</template> | ||
<MkCaptcha provider="hcaptcha" :sitekey="botProtectionForm.state.hcaptchaSiteKey || '10000000-ffff-ffff-ffff-000000000001'"/> | ||
<MkCaptcha v-model="hCaptchaResponse" provider="hcaptcha" :sitekey="botProtectionForm.state.hcaptchaSiteKey"/> | ||
</FormSlot> | ||
<MkInfo> | ||
<div :class="$style.captchaInfoMsg"> | ||
<div>サイトキーに"10000000-ffff-ffff-ffff-000000000001"と入力することで動作をテスト出来ます。<br/>本番運用時には必ず正規のサイトキーを設定してください。</div> | ||
<div>ref: <a href="https://docs.hcaptcha.com/#integration-testing-test-keys" target="_blank">hCaptcha Developer Guide</a></div> | ||
</div> | ||
</MkInfo> | ||
</template> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. テスト用のサイトキーがデフォルトで入るようになっていたのをやめました。 |
||
|
||
<template v-else-if="botProtectionForm.state.provider === 'mcaptcha'"> | ||
<MkInput v-model="botProtectionForm.state.mcaptchaSiteKey"> | ||
<template #prefix><i class="ti ti-key"></i></template> | ||
|
@@ -56,9 +63,10 @@ SPDX-License-Identifier: AGPL-3.0-only | |
</MkInput> | ||
<FormSlot v-if="botProtectionForm.state.mcaptchaSiteKey && botProtectionForm.state.mcaptchaInstanceUrl"> | ||
<template #label>{{ i18n.ts.preview }}</template> | ||
<MkCaptcha provider="mcaptcha" :sitekey="botProtectionForm.state.mcaptchaSiteKey" :instanceUrl="botProtectionForm.state.mcaptchaInstanceUrl"/> | ||
<MkCaptcha v-model="mCaptchaResponse" provider="mcaptcha" :sitekey="botProtectionForm.state.mcaptchaSiteKey" :instanceUrl="botProtectionForm.state.mcaptchaInstanceUrl"/> | ||
</FormSlot> | ||
</template> | ||
|
||
<template v-else-if="botProtectionForm.state.provider === 'recaptcha'"> | ||
<MkInput v-model="botProtectionForm.state.recaptchaSiteKey"> | ||
<template #prefix><i class="ti ti-key"></i></template> | ||
|
@@ -70,9 +78,16 @@ SPDX-License-Identifier: AGPL-3.0-only | |
</MkInput> | ||
<FormSlot v-if="botProtectionForm.state.recaptchaSiteKey"> | ||
<template #label>{{ i18n.ts.preview }}</template> | ||
<MkCaptcha provider="recaptcha" :sitekey="botProtectionForm.state.recaptchaSiteKey"/> | ||
<MkCaptcha v-model="reCaptchaResponse" provider="recaptcha" :sitekey="botProtectionForm.state.recaptchaSiteKey"/> | ||
</FormSlot> | ||
<MkInfo> | ||
<div :class="$style.captchaInfoMsg"> | ||
<div>サイトキーに"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"と入力することで動作をテスト出来ます。<br/>本番運用時には必ず正規のサイトキーを設定してください。</div> | ||
<div>ref: <a href="https://developers.google.com/recaptcha/docs/faq?hl=ja#id-like-to-run-automated-tests-with-recaptcha.-what-should-i-do" target="_blank">reCAPTCHA FAQ</a></div> | ||
</div> | ||
</MkInfo> | ||
</template> | ||
|
||
<template v-else-if="botProtectionForm.state.provider === 'turnstile'"> | ||
<MkInput v-model="botProtectionForm.state.turnstileSiteKey"> | ||
<template #prefix><i class="ti ti-key"></i></template> | ||
|
@@ -82,24 +97,31 @@ SPDX-License-Identifier: AGPL-3.0-only | |
<template #prefix><i class="ti ti-key"></i></template> | ||
<template #label>{{ i18n.ts.turnstileSecretKey }}</template> | ||
</MkInput> | ||
<FormSlot> | ||
<FormSlot v-if="botProtectionForm.state.turnstileSiteKey"> | ||
<template #label>{{ i18n.ts.preview }}</template> | ||
<MkCaptcha provider="turnstile" :sitekey="botProtectionForm.state.turnstileSiteKey || '1x00000000000000000000AA'"/> | ||
<MkCaptcha v-model="turnstileResponse" provider="turnstile" :sitekey="botProtectionForm.state.turnstileSiteKey"/> | ||
</FormSlot> | ||
<MkInfo> | ||
<div :class="$style.captchaInfoMsg"> | ||
<div>サイトキーに"1x00000000000000000000AA"と入力することで動作をテスト出来ます。<br/>本番運用時には必ず正規のサイトキーを設定してください。</div> | ||
<div>ref: <a href="https://developers.cloudflare.com/turnstile/troubleshooting/testing/" target="_blank">Cloudflare Docs</a></div> | ||
</div> | ||
</MkInfo> | ||
</template> | ||
|
||
<template v-else-if="botProtectionForm.state.provider === 'testcaptcha'"> | ||
<MkInfo warn><span v-html="i18n.ts.testCaptchaWarning"></span></MkInfo> | ||
<FormSlot> | ||
<template #label>{{ i18n.ts.preview }}</template> | ||
<MkCaptcha provider="testcaptcha"/> | ||
<MkCaptcha v-model="testCaptchaResponse" provider="testcaptcha" :sitekey="null"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 型エラーが出てたので |
||
</FormSlot> | ||
</template> | ||
</div> | ||
</MkFolder> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { defineAsyncComponent, ref } from 'vue'; | ||
import { computed, defineAsyncComponent, ref } from 'vue'; | ||
import MkRadios from '@/components/MkRadios.vue'; | ||
import MkInput from '@/components/MkInput.vue'; | ||
import FormSlot from '@/components/form/slot.vue'; | ||
|
@@ -116,6 +138,21 @@ const MkCaptcha = defineAsyncComponent(() => import('@/components/MkCaptcha.vue' | |
|
||
const meta = await misskeyApi('admin/meta'); | ||
|
||
const hCaptchaResponse = ref<string | null>(null); | ||
const mCaptchaResponse = ref<string | null>(null); | ||
const reCaptchaResponse = ref<string | null>(null); | ||
const turnstileResponse = ref<string | null>(null); | ||
const testCaptchaResponse = ref<string | null>(null); | ||
|
||
const canSaving = computed((): boolean => { | ||
return (botProtectionForm.state.provider === null) || | ||
(botProtectionForm.state.provider === 'hcaptcha' && !!hCaptchaResponse.value) || | ||
(botProtectionForm.state.provider === 'mcaptcha' && !!mCaptchaResponse.value) || | ||
(botProtectionForm.state.provider === 'recaptcha' && !!reCaptchaResponse.value) || | ||
(botProtectionForm.state.provider === 'turnstile' && !!turnstileResponse.value) || | ||
(botProtectionForm.state.provider === 'testcaptcha' && !!testCaptchaResponse.value); | ||
}); | ||
|
||
const botProtectionForm = useForm({ | ||
provider: meta.enableHcaptcha | ||
? 'hcaptcha' | ||
|
@@ -157,3 +194,11 @@ const botProtectionForm = useForm({ | |
fetchInstance(true); | ||
}); | ||
</script> | ||
|
||
<style lang="scss" module> | ||
.captchaInfoMsg { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 8px; | ||
} | ||
</style> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dev modeでreCAPTCHAが表示できなかったので