|
1 | 1 | <template> |
2 | 2 | <v-container justify="space-around"> |
3 | 3 | <v-row align-content="center" align="center"> |
4 | | - <v-col v-if="!is_captcha_validated" cols="12" align-self="center" align="center"> |
5 | | - <h4 class="pb-3"> |
6 | | - Please complete the recaptcha to launch the app |
7 | | - </h4> |
8 | | - <vue-recaptcha ref="recaptcha" :sitekey="site_key" :loadRecaptchaScript="true" |
9 | | - @expired="is_captcha_validated = false" @verify="submit_recaptcha" align-self="center" /> |
| 4 | + <v-col |
| 5 | + v-if="!is_captcha_validated" |
| 6 | + cols="12" |
| 7 | + align-self="center" |
| 8 | + align="center" |
| 9 | + > |
| 10 | + <h4 class="pb-3">Please complete the recaptcha to launch the app</h4> |
| 11 | + <vue-recaptcha |
| 12 | + ref="recaptcha" |
| 13 | + :sitekey="site_key" |
| 14 | + :loadRecaptchaScript="true" |
| 15 | + @expired="is_captcha_validated = false" |
| 16 | + @verify="submit_recaptcha" |
| 17 | + align-self="center" |
| 18 | + /> |
10 | 19 | </v-col> |
11 | 20 | <v-col v-if="!is_cloud_running && is_connexion_launched"> |
12 | 21 | <Loading /> |
|
16 | 25 | </template> |
17 | 26 |
|
18 | 27 | <script setup> |
19 | | -import { VueRecaptcha } from "vue-recaptcha" |
| 28 | + import { VueRecaptcha } from "vue-recaptcha" |
20 | 29 |
|
21 | | -const websocket_store = use_websocket_store() |
22 | | -const cloud_store = use_cloud_store() |
23 | | -const { is_cloud_running, is_captcha_validated, is_connexion_launched } = storeToRefs(cloud_store) |
| 30 | + const websocket_store = use_websocket_store() |
| 31 | + const cloud_store = use_cloud_store() |
| 32 | + const { is_cloud_running, is_captcha_validated, is_connexion_launched } = |
| 33 | + storeToRefs(cloud_store) |
24 | 34 |
|
25 | | -const site_key = useRuntimeConfig().public.RECAPTCHA_SITE_KEY |
| 35 | + const site_key = useRuntimeConfig().public.RECAPTCHA_SITE_KEY |
26 | 36 |
|
27 | | -watch(is_captcha_validated, async (value) => { |
28 | | - if (value === true && process.client) { |
29 | | - console.log('is_captcha_validated 2', is_captcha_validated.value) |
30 | | - await cloud_store.create_connexion() |
31 | | - console.log('is_captcha_validated 3', is_captcha_validated.value) |
32 | | - await websocket_store.ws_connect() |
33 | | - console.log('is_captcha_validated 4', is_captcha_validated.value) |
34 | | - } |
35 | | -}) |
| 37 | + watch(is_captcha_validated, async (value) => { |
| 38 | + if (value === true && process.client) { |
| 39 | + console.log("is_captcha_validated 2", is_captcha_validated.value) |
| 40 | + await cloud_store.create_connexion() |
| 41 | + console.log("is_captcha_validated 3", is_captcha_validated.value) |
| 42 | + await websocket_store.ws_connect() |
| 43 | + console.log("is_captcha_validated 4", is_captcha_validated.value) |
| 44 | + } |
| 45 | + }) |
36 | 46 |
|
37 | | -onMounted(() => { |
38 | | - if (process.client) { |
39 | | - const config = useRuntimeConfig() |
40 | | - if (config.public.NODE_ENV !== 'production') { |
41 | | - cloud_store.$patch({ is_captcha_validated: true }) |
42 | | - console.log('is_captcha_validated', is_captcha_validated.value) |
| 47 | + onMounted(() => { |
| 48 | + if (process.client) { |
| 49 | + const config = useRuntimeConfig() |
| 50 | + if (config.public.NODE_ENV !== "production") { |
| 51 | + cloud_store.$patch({ is_captcha_validated: true }) |
| 52 | + console.log("is_captcha_validated", is_captcha_validated.value) |
| 53 | + } |
43 | 54 | } |
44 | | - } |
45 | | -}) |
| 55 | + }) |
46 | 56 |
|
47 | | -async function submit_recaptcha (token) { |
48 | | - try { |
49 | | - const response = await $fetch.raw(`/.netlify/functions/recaptcha?token=${token}`) |
50 | | - cloud_store.$patch({ is_captcha_validated: response.status == 200 }) |
51 | | - recaptcha.reset() |
52 | | - } catch (error) { |
53 | | - console.error(error) |
| 57 | + async function submit_recaptcha(token) { |
| 58 | + try { |
| 59 | + const response = await $fetch.raw( |
| 60 | + `/.netlify/functions/recaptcha?token=${token}`, |
| 61 | + ) |
| 62 | + cloud_store.$patch({ is_captcha_validated: response.status == 200 }) |
| 63 | + recaptcha.reset() |
| 64 | + } catch (error) { |
| 65 | + console.error(error) |
| 66 | + } |
54 | 67 | } |
55 | | -} |
56 | 68 | </script> |
0 commit comments