|
20 | 20 | </template> |
21 | 21 |
|
22 | 22 | <script setup> |
23 | | - import { VueRecaptcha } from "vue-recaptcha" |
24 | | - const websocket_store = use_websocket_store() |
25 | | - const cloud_store = use_cloud_store() |
26 | | - const { is_captcha_validated } = storeToRefs(cloud_store) |
| 23 | + import { VueRecaptcha } from "vue-recaptcha" |
| 24 | + const websocket_store = use_websocket_store() |
| 25 | + const cloud_store = use_cloud_store() |
| 26 | + const { is_captcha_validated } = storeToRefs(cloud_store) |
27 | 27 |
|
28 | | - watch(is_captcha_validated, async (value) => { |
29 | | - if (value === true && process.client) { |
30 | | - await cloud_store.create_connexion() |
31 | | - await websocket_store.ws_connect() |
32 | | - } |
33 | | - }) |
| 28 | + const site_key = useRuntimeConfig().public.RECAPTCHA_SITE_KEY |
| 29 | +
|
| 30 | + watch(is_captcha_validated, async (value) => { |
| 31 | + if (value === true && process.client) { |
| 32 | + await cloud_store.create_connexion() |
| 33 | + await websocket_store.ws_connect() |
| 34 | + } |
| 35 | + }) |
34 | 36 |
|
35 | | - onMounted(() => { |
36 | | - console.log("onMounted", useRuntimeConfig()) |
37 | | - }) |
| 37 | + onMounted(() => { |
| 38 | + <<<<<<< HEAD |
| 39 | + console.log("onMounted", useRuntimeConfig()) |
| 40 | + }) |
| 41 | + ======= |
| 42 | + if (process.client) { |
| 43 | + console.log("useRuntimeConfig()", useRuntimeConfig()) |
| 44 | + const config = useRuntimeConfig() |
| 45 | + if (config.public.NODE_ENV !== "production") { |
| 46 | + cloud_store.$patch({ is_captcha_validated: true }) |
| 47 | + } |
| 48 | + } |
| 49 | + }) |
| 50 | +
|
| 51 | + async function submit_recaptcha(token) { |
| 52 | + try { |
| 53 | + const response = await $fetch.raw( |
| 54 | + `/.netlify/functions/recaptcha?token=${token}`, |
| 55 | + ) |
| 56 | + cloud_store.$patch({ is_captcha_validated: response.status == 200 }) |
| 57 | + recaptcha.reset() |
| 58 | + } catch (error) { |
| 59 | + console.error(error) |
| 60 | + } |
| 61 | + } |
| 62 | + >>>>>>> 96ad5440029efa83fba9a0825d38e5ca6625e9ae |
38 | 63 | </script> |
0 commit comments