|
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 | + <Recaptcha /> |
10 | 12 | </v-col> |
11 | | - <v-col v-else-if="!cloud_store.is_running && cloud_store.is_connexion_launched"> |
| 13 | + <v-col |
| 14 | + v-else-if="!cloud_store.is_running && cloud_store.is_connexion_launched" |
| 15 | + > |
12 | 16 | <Loading /> |
13 | 17 | </v-col> |
14 | 18 | </v-row> |
15 | 19 | </v-container> |
16 | 20 | </template> |
17 | 21 |
|
18 | 22 | <script setup> |
19 | | -import { VueRecaptcha } from "vue-recaptcha" |
20 | | -
|
21 | | -const websocket_store = use_websocket_store() |
22 | | -const cloud_store = use_cloud_store() |
23 | | -const { is_captcha_validated } = storeToRefs(cloud_store) |
24 | | -
|
25 | | -const props = defineProps({ |
26 | | - site_key: { type: String, required: true } |
27 | | -}) |
| 23 | +const websocket_store = use_websocket_store(); |
| 24 | +const cloud_store = use_cloud_store(); |
| 25 | +const { is_captcha_validated } = storeToRefs(cloud_store); |
28 | 26 |
|
29 | 27 | watch(is_captcha_validated, async (value) => { |
30 | 28 | if (value === true && process.client) { |
31 | | - await cloud_store.create_connexion() |
32 | | - await websocket_store.ws_connect() |
33 | | - } |
34 | | -}) |
35 | | -
|
36 | | -onMounted(() => { |
37 | | - if (process.client) { |
38 | | - const config = useRuntimeConfig() |
39 | | - if (config.public.NODE_ENV !== 'production') { |
40 | | - cloud_store.$patch({ is_captcha_validated: true }) |
41 | | - } |
42 | | - } |
43 | | -}) |
44 | | -
|
45 | | -async function submit_recaptcha (token) { |
46 | | - try { |
47 | | - const response = await $fetch.raw(`/.netlify/functions/recaptcha?token=${token}`) |
48 | | - cloud_store.$patch({ is_captcha_validated: response.status == 200 }) |
49 | | - recaptcha.reset() |
50 | | - } catch (error) { |
51 | | - console.error(error) |
| 29 | + await cloud_store.create_connexion(); |
| 30 | + await websocket_store.ws_connect(); |
52 | 31 | } |
53 | | -} |
| 32 | +}); |
54 | 33 | </script> |
0 commit comments