aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/features/mcaptcha.js
blob: 725e2e28acf119fcc8903ed9cd00078b92edc7bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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,
    }
  });
}