Skip to content

Commit 21eb852

Browse files
fix(recaptcha): revert changes
1 parent 48ad73f commit 21eb852

File tree

2 files changed

+30
-50
lines changed

2 files changed

+30
-50
lines changed

components/Launcher.vue

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@
88
align="center"
99
>
1010
<h4 class="pb-3">Please complete the recaptcha to launch the app</h4>
11-
<Recaptcha :site_key="site_key" />
11+
<ClientOnly>
12+
<vue-recaptcha
13+
ref="recaptcha"
14+
:sitekey="site_key"
15+
:loadRecaptchaScript="true"
16+
@expired="is_captcha_validated = false"
17+
@verify="submit_recaptcha"
18+
align-self="center"
19+
/>
20+
</ClientOnly>
1221
</v-col>
1322
<v-col
1423
v-else-if="!cloud_store.is_running && cloud_store.is_connexion_launched"
@@ -20,6 +29,7 @@
2029
</template>
2130

2231
<script setup>
32+
import { VueRecaptcha } from "vue-recaptcha"
2333
const websocket_store = use_websocket_store()
2434
const cloud_store = use_cloud_store()
2535
const { is_captcha_validated } = storeToRefs(cloud_store)
@@ -33,8 +43,24 @@
3343
}
3444
})
3545
36-
onMounted(async () => {
37-
console.log("useRuntimeConfig()", useRuntimeConfig())
38-
console.log("site_key", site_key)
46+
onMounted(() => {
47+
if (process.client) {
48+
const config = useRuntimeConfig()
49+
if (config.public.NODE_ENV !== "production") {
50+
cloud_store.$patch({ is_captcha_validated: true })
51+
}
52+
}
3953
})
54+
55+
async function submit_recaptcha(token) {
56+
try {
57+
const response = await $fetch.raw(
58+
`/.netlify/functions/recaptcha?token=${token}`,
59+
)
60+
cloud_store.$patch({ is_captcha_validated: response.status == 200 })
61+
recaptcha.reset()
62+
} catch (error) {
63+
console.error(error)
64+
}
65+
}
4066
</script>

components/Recaptcha.vue

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)