aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/features/mcaptcha.js
diff options
context:
space:
mode:
Diffstat (limited to 'web_src/js/features/mcaptcha.js')
-rw-r--r--web_src/js/features/mcaptcha.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/web_src/js/features/mcaptcha.js b/web_src/js/features/mcaptcha.js
new file mode 100644
index 0000000000..725e2e28ac
--- /dev/null
+++ b/web_src/js/features/mcaptcha.js
@@ -0,0 +1,16 @@
+export async function initMcaptcha() {
+ const mCaptchaEl = document.querySelector('.m-captcha');
+ if (!mCaptchaEl) return;
+
+ const {default: mCaptcha} = await import(/* webpackChunkName: "mcaptcha-vanilla-glue" */'@mcaptcha/vanilla-glue');
+ mCaptcha.INPUT_NAME = 'm-captcha-response';
+ const siteKey = mCaptchaEl.getAttribute('data-sitekey');
+ const instanceURL = mCaptchaEl.getAttribute('data-instance-url');
+
+ mCaptcha.default({
+ siteKey: {
+ instanceUrl: new URL(instanceURL),
+ key: siteKey,
+ }
+ });
+}