Skip to content

Commit e72c12b

Browse files
Merge pull request #43 from Geode-solutions/fix_recaptcha
Fix recaptcha
2 parents d2604c6 + b6234c3 commit e72c12b

File tree

3 files changed

+56
-35
lines changed

3 files changed

+56
-35
lines changed

.eslintrc.cjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true,
5+
browser: true,
6+
es2021: true,
7+
},
8+
extends: [
9+
"eslint:recommended",
10+
"plugin:vue/vue3-recommended",
11+
"plugin:vuetify/recommended",
12+
"plugin:nuxt/recommended",
13+
],
14+
}

components/Launcher.vue

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,7 @@
88
align="center"
99
>
1010
<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-
/>
11+
<Recaptcha />
1912
</v-col>
2013
<v-col
2114
v-else-if="!cloud_store.is_running && cloud_store.is_connexion_launched"
@@ -27,41 +20,14 @@
2720
</template>
2821

2922
<script setup>
30-
import { VueRecaptcha } from "vue-recaptcha"
31-
3223
const websocket_store = use_websocket_store()
3324
const cloud_store = use_cloud_store()
3425
const { is_captcha_validated } = storeToRefs(cloud_store)
3526
36-
const props = defineProps({
37-
site_key: { type: String, required: true },
38-
})
39-
4027
watch(is_captcha_validated, async (value) => {
4128
if (value === true && process.client) {
4229
await cloud_store.create_connexion()
4330
await websocket_store.ws_connect()
4431
}
4532
})
46-
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-
}
53-
}
54-
})
55-
56-
async function submit_recaptcha(token) {
57-
try {
58-
const response = await $fetch.raw(
59-
`/.netlify/functions/recaptcha?token=${token}`,
60-
)
61-
cloud_store.$patch({ is_captcha_validated: response.status == 200 })
62-
recaptcha.reset()
63-
} catch (error) {
64-
console.error(error)
65-
}
66-
}
6733
</script>

components/Recaptcha.vue

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<template>
2+
<vue-recaptcha
3+
ref="recaptcha"
4+
:sitekey="site_key"
5+
:loadRecaptchaScript="true"
6+
@expired="is_captcha_validated = false"
7+
@verify="submit_recaptcha"
8+
align-self="center"
9+
/>
10+
</template>
11+
12+
<script setup>
13+
import { VueRecaptcha } from "vue-recaptcha"
14+
15+
const websocket_store = use_websocket_store()
16+
const cloud_store = use_cloud_store()
17+
const { is_captcha_validated } = storeToRefs(cloud_store)
18+
19+
const site_key = useRuntimeConfig().public.RECAPTCHA_SITE_KEY
20+
21+
onMounted(() => {
22+
if (process.client) {
23+
const config = useRuntimeConfig()
24+
if (config.public.NODE_ENV !== "production") {
25+
cloud_store.$patch({ is_captcha_validated: true })
26+
}
27+
}
28+
})
29+
30+
async function submit_recaptcha(token) {
31+
try {
32+
const response = await $fetch.raw(
33+
`/.netlify/functions/recaptcha?token=${token}`,
34+
)
35+
cloud_store.$patch({ is_captcha_validated: response.status == 200 })
36+
recaptcha.reset()
37+
} catch (error) {
38+
console.error(error)
39+
}
40+
}
41+
</script>

0 commit comments

Comments
 (0)