feat: Add support for mCaptcha (#12905)
* feat: Add support for mCaptcha * fix: Fix docker compose configuration * chore(frontend/docs): update changelog & fix eslint errors * `@mcaptcha/vanilla-glue`をダイナミックインポートするように * chore: Add missing prefix to CHANGELOG * refactor(backend): 適当につけた変数の名前を変更
This commit is contained in:
parent
b55a6a80e1
commit
072f67d6e7
24 changed files with 336 additions and 62 deletions
|
@ -10,6 +10,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<MkRadios v-model="provider">
|
||||
<option :value="null">{{ i18n.ts.none }} ({{ i18n.ts.notRecommended }})</option>
|
||||
<option value="hcaptcha">hCaptcha</option>
|
||||
<option value="mcaptcha">mCaptcha</option>
|
||||
<option value="recaptcha">reCAPTCHA</option>
|
||||
<option value="turnstile">Turnstile</option>
|
||||
</MkRadios>
|
||||
|
@ -28,6 +29,24 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<MkCaptcha provider="hcaptcha" :sitekey="hcaptchaSiteKey || '10000000-ffff-ffff-ffff-000000000001'"/>
|
||||
</FormSlot>
|
||||
</template>
|
||||
<template v-else-if="provider === 'mcaptcha'">
|
||||
<MkInput v-model="mcaptchaSiteKey">
|
||||
<template #prefix><i class="ti ti-key"></i></template>
|
||||
<template #label>{{ i18n.ts.mcaptchaSiteKey }}</template>
|
||||
</MkInput>
|
||||
<MkInput v-model="mcaptchaSecretKey">
|
||||
<template #prefix><i class="ti ti-key"></i></template>
|
||||
<template #label>{{ i18n.ts.mcaptchaSecretKey }}</template>
|
||||
</MkInput>
|
||||
<MkInput v-model="mcaptchaInstanceUrl">
|
||||
<template #prefix><i class="ti ti-link"></i></template>
|
||||
<template #label>{{ i18n.ts.mcaptchaInstanceUrl }}</template>
|
||||
</MkInput>
|
||||
<FormSlot v-if="mcaptchaSiteKey && mcaptchaInstanceUrl">
|
||||
<template #label>{{ i18n.ts.preview }}</template>
|
||||
<MkCaptcha provider="mcaptcha" :sitekey="mcaptchaSiteKey" :instanceUrl="mcaptchaInstanceUrl"/>
|
||||
</FormSlot>
|
||||
</template>
|
||||
<template v-else-if="provider === 'recaptcha'">
|
||||
<MkInput v-model="recaptchaSiteKey">
|
||||
<template #prefix><i class="ti ti-key"></i></template>
|
||||
|
@ -81,6 +100,9 @@ const MkCaptcha = defineAsyncComponent(() => import('@/components/MkCaptcha.vue'
|
|||
const provider = ref<CaptchaProvider | null>(null);
|
||||
const hcaptchaSiteKey = ref<string | null>(null);
|
||||
const hcaptchaSecretKey = ref<string | null>(null);
|
||||
const mcaptchaSiteKey = ref<string | null>(null);
|
||||
const mcaptchaSecretKey = ref<string | null>(null);
|
||||
const mcaptchaInstanceUrl = ref<string | null>(null);
|
||||
const recaptchaSiteKey = ref<string | null>(null);
|
||||
const recaptchaSecretKey = ref<string | null>(null);
|
||||
const turnstileSiteKey = ref<string | null>(null);
|
||||
|
@ -90,12 +112,18 @@ async function init() {
|
|||
const meta = await misskeyApi('admin/meta');
|
||||
hcaptchaSiteKey.value = meta.hcaptchaSiteKey;
|
||||
hcaptchaSecretKey.value = meta.hcaptchaSecretKey;
|
||||
mcaptchaSiteKey.value = meta.mcaptchaSiteKey;
|
||||
mcaptchaSecretKey.value = meta.mcaptchaSecretKey;
|
||||
mcaptchaInstanceUrl.value = meta.mcaptchaInstanceUrl;
|
||||
recaptchaSiteKey.value = meta.recaptchaSiteKey;
|
||||
recaptchaSecretKey.value = meta.recaptchaSecretKey;
|
||||
turnstileSiteKey.value = meta.turnstileSiteKey;
|
||||
turnstileSecretKey.value = meta.turnstileSecretKey;
|
||||
|
||||
provider.value = meta.enableHcaptcha ? 'hcaptcha' : meta.enableRecaptcha ? 'recaptcha' : meta.enableTurnstile ? 'turnstile' : null;
|
||||
provider.value = meta.enableHcaptcha ? 'hcaptcha' :
|
||||
meta.enableRecaptcha ? 'recaptcha' :
|
||||
meta.enableTurnstile ? 'turnstile' :
|
||||
meta.enableMcaptcha ? 'mcaptcha' : null;
|
||||
}
|
||||
|
||||
function save() {
|
||||
|
@ -103,6 +131,10 @@ function save() {
|
|||
enableHcaptcha: provider.value === 'hcaptcha',
|
||||
hcaptchaSiteKey: hcaptchaSiteKey.value,
|
||||
hcaptchaSecretKey: hcaptchaSecretKey.value,
|
||||
enableMcaptcha: provider.value === 'mcaptcha',
|
||||
mcaptchaSiteKey: mcaptchaSiteKey.value,
|
||||
mcaptchaSecretKey: mcaptchaSecretKey.value,
|
||||
mcaptchaInstanceUrl: mcaptchaInstanceUrl.value,
|
||||
enableRecaptcha: provider.value === 'recaptcha',
|
||||
recaptchaSiteKey: recaptchaSiteKey.value,
|
||||
recaptchaSecretKey: recaptchaSecretKey.value,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue