2023-07-27 00:31:52 -05:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2021-04-22 08:29:33 -05:00
|
|
|
<template>
|
2022-01-04 06:16:41 -06:00
|
|
|
<div>
|
2021-04-22 08:29:33 -05:00
|
|
|
<FormSuspense :p="init">
|
2023-01-05 22:40:17 -06:00
|
|
|
<div class="_gaps_m">
|
2023-01-07 00:09:46 -06:00
|
|
|
<MkRadios v-model="provider">
|
2022-07-20 08:24:26 -05:00
|
|
|
<option :value="null">{{ i18n.ts.none }} ({{ i18n.ts.notRecommended }})</option>
|
2022-01-04 06:16:41 -06:00
|
|
|
<option value="hcaptcha">hCaptcha</option>
|
2024-01-06 05:14:33 -06:00
|
|
|
<option value="mcaptcha">mCaptcha</option>
|
2022-01-04 06:16:41 -06:00
|
|
|
<option value="recaptcha">reCAPTCHA</option>
|
2022-10-12 19:19:57 -05:00
|
|
|
<option value="turnstile">Turnstile</option>
|
2023-01-07 00:09:46 -06:00
|
|
|
</MkRadios>
|
2021-04-22 08:29:33 -05:00
|
|
|
|
2022-01-04 06:16:41 -06:00
|
|
|
<template v-if="provider === 'hcaptcha'">
|
2023-01-07 00:09:46 -06:00
|
|
|
<MkInput v-model="hcaptchaSiteKey">
|
2022-12-19 04:01:30 -06:00
|
|
|
<template #prefix><i class="ti ti-key"></i></template>
|
2022-07-20 08:24:26 -05:00
|
|
|
<template #label>{{ i18n.ts.hcaptchaSiteKey }}</template>
|
2023-01-07 00:09:46 -06:00
|
|
|
</MkInput>
|
|
|
|
<MkInput v-model="hcaptchaSecretKey">
|
2022-12-19 04:01:30 -06:00
|
|
|
<template #prefix><i class="ti ti-key"></i></template>
|
2022-07-20 08:24:26 -05:00
|
|
|
<template #label>{{ i18n.ts.hcaptchaSecretKey }}</template>
|
2023-01-07 00:09:46 -06:00
|
|
|
</MkInput>
|
2023-01-05 06:04:56 -06:00
|
|
|
<FormSlot>
|
2022-07-20 08:24:26 -05:00
|
|
|
<template #label>{{ i18n.ts.preview }}</template>
|
2021-04-22 08:29:33 -05:00
|
|
|
<MkCaptcha provider="hcaptcha" :sitekey="hcaptchaSiteKey || '10000000-ffff-ffff-ffff-000000000001'"/>
|
2022-01-04 06:16:41 -06:00
|
|
|
</FormSlot>
|
|
|
|
</template>
|
2024-01-06 05:14:33 -06:00
|
|
|
<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>
|
2022-01-04 06:16:41 -06:00
|
|
|
<template v-else-if="provider === 'recaptcha'">
|
2023-01-07 00:09:46 -06:00
|
|
|
<MkInput v-model="recaptchaSiteKey">
|
2022-12-19 04:01:30 -06:00
|
|
|
<template #prefix><i class="ti ti-key"></i></template>
|
2022-07-20 08:24:26 -05:00
|
|
|
<template #label>{{ i18n.ts.recaptchaSiteKey }}</template>
|
2023-01-07 00:09:46 -06:00
|
|
|
</MkInput>
|
|
|
|
<MkInput v-model="recaptchaSecretKey">
|
2022-12-19 04:01:30 -06:00
|
|
|
<template #prefix><i class="ti ti-key"></i></template>
|
2022-07-20 08:24:26 -05:00
|
|
|
<template #label>{{ i18n.ts.recaptchaSecretKey }}</template>
|
2023-01-07 00:09:46 -06:00
|
|
|
</MkInput>
|
2023-01-05 06:04:56 -06:00
|
|
|
<FormSlot v-if="recaptchaSiteKey">
|
2022-07-20 08:24:26 -05:00
|
|
|
<template #label>{{ i18n.ts.preview }}</template>
|
2021-04-22 08:29:33 -05:00
|
|
|
<MkCaptcha provider="recaptcha" :sitekey="recaptchaSiteKey"/>
|
2022-01-04 06:16:41 -06:00
|
|
|
</FormSlot>
|
|
|
|
</template>
|
2022-10-12 19:19:57 -05:00
|
|
|
<template v-else-if="provider === 'turnstile'">
|
2023-01-07 00:09:46 -06:00
|
|
|
<MkInput v-model="turnstileSiteKey">
|
2022-12-19 04:01:30 -06:00
|
|
|
<template #prefix><i class="ti ti-key"></i></template>
|
2022-10-12 19:19:57 -05:00
|
|
|
<template #label>{{ i18n.ts.turnstileSiteKey }}</template>
|
2023-01-07 00:09:46 -06:00
|
|
|
</MkInput>
|
|
|
|
<MkInput v-model="turnstileSecretKey">
|
2022-12-19 04:01:30 -06:00
|
|
|
<template #prefix><i class="ti ti-key"></i></template>
|
2022-10-12 19:19:57 -05:00
|
|
|
<template #label>{{ i18n.ts.turnstileSecretKey }}</template>
|
2023-01-07 00:09:46 -06:00
|
|
|
</MkInput>
|
2023-01-05 06:04:56 -06:00
|
|
|
<FormSlot>
|
2022-10-12 19:19:57 -05:00
|
|
|
<template #label>{{ i18n.ts.preview }}</template>
|
|
|
|
<MkCaptcha provider="turnstile" :sitekey="turnstileSiteKey || '1x00000000000000000000AA'"/>
|
|
|
|
</FormSlot>
|
|
|
|
</template>
|
2021-04-22 08:29:33 -05:00
|
|
|
|
2023-01-05 18:41:14 -06:00
|
|
|
<MkButton primary @click="save"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton>
|
2022-01-04 06:16:41 -06:00
|
|
|
</div>
|
2021-04-22 08:29:33 -05:00
|
|
|
</FormSuspense>
|
2022-01-04 06:16:41 -06:00
|
|
|
</div>
|
2021-04-22 08:29:33 -05:00
|
|
|
</template>
|
|
|
|
|
2022-05-14 07:34:50 -05:00
|
|
|
<script lang="ts" setup>
|
2023-12-06 23:42:09 -06:00
|
|
|
import { defineAsyncComponent, ref } from 'vue';
|
2023-12-25 23:19:35 -06:00
|
|
|
import type { CaptchaProvider } from '@/components/MkCaptcha.vue';
|
2023-01-07 00:09:46 -06:00
|
|
|
import MkRadios from '@/components/MkRadios.vue';
|
|
|
|
import MkInput from '@/components/MkInput.vue';
|
2023-01-05 18:41:14 -06:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2022-01-04 06:16:41 -06:00
|
|
|
import FormSuspense from '@/components/form/suspense.vue';
|
|
|
|
import FormSlot from '@/components/form/slot.vue';
|
2023-09-19 02:37:43 -05:00
|
|
|
import * as os from '@/os.js';
|
2024-01-04 03:32:46 -06:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-09-19 02:37:43 -05:00
|
|
|
import { fetchInstance } from '@/instance.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
2021-04-22 08:29:33 -05:00
|
|
|
|
2022-08-30 10:24:33 -05:00
|
|
|
const MkCaptcha = defineAsyncComponent(() => import('@/components/MkCaptcha.vue'));
|
2021-04-22 08:29:33 -05:00
|
|
|
|
2023-12-25 23:19:35 -06:00
|
|
|
const provider = ref<CaptchaProvider | null>(null);
|
2023-12-06 23:42:09 -06:00
|
|
|
const hcaptchaSiteKey = ref<string | null>(null);
|
|
|
|
const hcaptchaSecretKey = ref<string | null>(null);
|
2024-01-06 05:14:33 -06:00
|
|
|
const mcaptchaSiteKey = ref<string | null>(null);
|
|
|
|
const mcaptchaSecretKey = ref<string | null>(null);
|
|
|
|
const mcaptchaInstanceUrl = ref<string | null>(null);
|
2023-12-06 23:42:09 -06:00
|
|
|
const recaptchaSiteKey = ref<string | null>(null);
|
|
|
|
const recaptchaSecretKey = ref<string | null>(null);
|
|
|
|
const turnstileSiteKey = ref<string | null>(null);
|
|
|
|
const turnstileSecretKey = ref<string | null>(null);
|
2021-04-22 08:29:33 -05:00
|
|
|
|
2022-05-14 07:34:50 -05:00
|
|
|
async function init() {
|
2024-01-04 03:32:46 -06:00
|
|
|
const meta = await misskeyApi('admin/meta');
|
2023-12-06 23:42:09 -06:00
|
|
|
hcaptchaSiteKey.value = meta.hcaptchaSiteKey;
|
|
|
|
hcaptchaSecretKey.value = meta.hcaptchaSecretKey;
|
2024-01-06 05:14:33 -06:00
|
|
|
mcaptchaSiteKey.value = meta.mcaptchaSiteKey;
|
|
|
|
mcaptchaSecretKey.value = meta.mcaptchaSecretKey;
|
|
|
|
mcaptchaInstanceUrl.value = meta.mcaptchaInstanceUrl;
|
2023-12-06 23:42:09 -06:00
|
|
|
recaptchaSiteKey.value = meta.recaptchaSiteKey;
|
|
|
|
recaptchaSecretKey.value = meta.recaptchaSecretKey;
|
|
|
|
turnstileSiteKey.value = meta.turnstileSiteKey;
|
|
|
|
turnstileSecretKey.value = meta.turnstileSecretKey;
|
2021-04-22 08:29:33 -05:00
|
|
|
|
2024-01-06 05:14:33 -06:00
|
|
|
provider.value = meta.enableHcaptcha ? 'hcaptcha' :
|
|
|
|
meta.enableRecaptcha ? 'recaptcha' :
|
|
|
|
meta.enableTurnstile ? 'turnstile' :
|
|
|
|
meta.enableMcaptcha ? 'mcaptcha' : null;
|
2022-05-14 07:34:50 -05:00
|
|
|
}
|
2021-04-22 08:29:33 -05:00
|
|
|
|
2022-05-14 07:34:50 -05:00
|
|
|
function save() {
|
|
|
|
os.apiWithDialog('admin/update-meta', {
|
2023-12-06 23:42:09 -06:00
|
|
|
enableHcaptcha: provider.value === 'hcaptcha',
|
|
|
|
hcaptchaSiteKey: hcaptchaSiteKey.value,
|
|
|
|
hcaptchaSecretKey: hcaptchaSecretKey.value,
|
2024-01-06 05:14:33 -06:00
|
|
|
enableMcaptcha: provider.value === 'mcaptcha',
|
|
|
|
mcaptchaSiteKey: mcaptchaSiteKey.value,
|
|
|
|
mcaptchaSecretKey: mcaptchaSecretKey.value,
|
|
|
|
mcaptchaInstanceUrl: mcaptchaInstanceUrl.value,
|
2023-12-06 23:42:09 -06:00
|
|
|
enableRecaptcha: provider.value === 'recaptcha',
|
|
|
|
recaptchaSiteKey: recaptchaSiteKey.value,
|
|
|
|
recaptchaSecretKey: recaptchaSecretKey.value,
|
|
|
|
enableTurnstile: provider.value === 'turnstile',
|
|
|
|
turnstileSiteKey: turnstileSiteKey.value,
|
|
|
|
turnstileSecretKey: turnstileSecretKey.value,
|
2022-05-14 07:34:50 -05:00
|
|
|
}).then(() => {
|
|
|
|
fetchInstance();
|
|
|
|
});
|
|
|
|
}
|
2021-04-22 08:29:33 -05:00
|
|
|
</script>
|