diff --git a/nuxt.config.ts b/nuxt.config.ts index 574b3f9..9d1a71a 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -24,7 +24,11 @@ export default defineNuxtConfig({ }, runtimeConfig: { - apiBase: 'https://api.pretendo.cc' + apiBase: 'https://api.pretendo.cc', + + public: { + hCaptchaSitekey: '' + } }, css: ['~/assets/css/main.css'], diff --git a/src/pages/account/register/index.vue b/src/pages/account/register/index.vue index be309cf..3f19ce1 100644 --- a/src/pages/account/register/index.vue +++ b/src/pages/account/register/index.vue @@ -12,35 +12,33 @@ const errorMessage = ref(); const invisibleHcaptcha = ref(null); async function registerSubmission() { - if (invisibleHcaptcha.value) { - try { - const hCaptchaResponse = (await invisibleHcaptcha.value.executeAsync()).response; + try { + const hCaptchaResponse = invisibleHcaptcha.value ? (await invisibleHcaptcha.value.executeAsync()).response : null; - await $fetch('/api/account/register', { - method: 'POST', - body: { ...registerForm, hCaptchaResponse } - }); + await $fetch('/api/account/register', { + method: 'POST', + body: { ...registerForm, hCaptchaResponse } + }); - if (typeof redirect.value === 'string') { - await navigateTo(redirect.value); - } else { - await navigateTo('/account'); - } - } catch (error: unknown) { - if (error instanceof FetchError) { - errorMessage.value = error.statusText; - } else { - if (error === 'challenge-closed') { // Thrown if the captcha is closed, can be safely ignored - return; - } - - errorMessage.value = `Error during registration: ${error}`; // TODO: localize - } - - setTimeout(() => { // TODO: replace this toast - errorMessage.value = null; - }, 5000); + if (typeof redirect.value === 'string') { + await navigateTo(redirect.value); + } else { + await navigateTo('/account'); } + } catch (error: unknown) { + if (error instanceof FetchError) { + errorMessage.value = error.statusText; + } else { + if (error === 'challenge-closed') { // Thrown if the captcha is closed, can be safely ignored + return; + } + + errorMessage.value = `Error during registration: ${error}`; // TODO: localize + } + + setTimeout(() => { // TODO: replace this toast + errorMessage.value = null; + }, 5000); } } @@ -119,8 +117,9 @@ async function registerSubmission() {