Skip to content

Commit 2f3aaec

Browse files
save wip
1 parent 00a9c50 commit 2f3aaec

5 files changed

Lines changed: 103 additions & 7 deletions

File tree

app/components/TestRecaptcha.vue

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<template>
2+
<VRow align="center" justify="center">
3+
<VCol>
4+
<VForm v-model="valid">
5+
<VContainer>
6+
<VRow>
7+
<VCol cols="12" md="4" justify="center">
8+
<VTextField v-model="name" label="Name" required />
9+
</VCol>
10+
<VCol cols="12" md="4">
11+
<VTextField
12+
v-model="email"
13+
:rules="emailRules"
14+
label="E-mail"
15+
required
16+
/>
17+
</VCol>
18+
<VCol cols="12" md="4">
19+
<VCheckbox label="Launch the app" v-model="launch" />
20+
</VCol>
21+
</VRow>
22+
</VContainer>
23+
</VForm>
24+
</VCol>
25+
</VRow>
26+
<VRow align="center" justify="center">
27+
<VCol align="center" justify="center">
28+
<VBtn
29+
:text="props.button_label"
30+
:color="props.button_color"
31+
@click="submit_recaptcha"
32+
/>
33+
</VCol>
34+
</VRow>
35+
</template>
36+
37+
<script setup>
38+
const props = defineProps({
39+
button_label: {
40+
type: String,
41+
required: false,
42+
default: "Click to launch the app",
43+
},
44+
button_color: {
45+
type: String,
46+
required: false,
47+
default: "primary",
48+
},
49+
});
50+
const infra_store = useInfraStore();
51+
const name = ref("");
52+
const email = ref("");
53+
const launch = ref(false);
54+
const emailRules = [
55+
(value) => {
56+
if (value) return true;
57+
58+
return "E-mail is required.";
59+
},
60+
(value) => {
61+
if (/.+@.+\..+/.test(value)) return true;
62+
63+
return "E-mail must be valid.";
64+
},
65+
];
66+
67+
onMounted(() => {
68+
if (import.meta.client) {
69+
if (
70+
process.env.NODE_ENV !== "production" ||
71+
infra_store.app_mode !== appMode.appMode.CLOUD
72+
) {
73+
infra_store.$patch({ is_captcha_validated: true });
74+
}
75+
}
76+
});
77+
async function submit_recaptcha() {
78+
$fetch(
79+
`/.netlify/functions/recaptcha?name=${name.value}&email=${email.value}&launch=${launch.value}`,
80+
{
81+
onRequestError({ error }) {
82+
console.log("onRequestError", error);
83+
},
84+
onResponse({ response }) {
85+
if (response.ok) {
86+
infra_store.$patch({
87+
is_captcha_validated: response.status == 200,
88+
});
89+
}
90+
},
91+
onResponseError({ response }) {},
92+
}
93+
);
94+
}
95+
</script>

app/pages/index.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
2-
<Launcher v-if="infra_store.status != Status.CREATED" />
2+
<TestRecaptcha />
3+
<!-- <Launcher v-if="infra_store.status != Status.CREATED" />
34
<v-card
45
v-else
56
ref="cardContainer"
@@ -19,7 +20,7 @@
1920
/>
2021
</template>
2122
</HybridRenderingView>
22-
</v-card>
23+
</v-card> -->
2324
</template>
2425

2526
<script setup>

netlify/functions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"author": "Geode-solutions",
66
"license": "MIT",
77
"dependencies": {
8-
"axios": "^1.4.0"
8+
"@geode-opengeodeweb-front": "9.11.0-rc.11"
99
}
1010
}

netlify/functions/recaptcha.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
import { check_recaptcha_params } from "./recaptcha.js";
2+
13
exports.handler = async function (event) {
24
const { name, email, launch } = event.queryStringParameters.name;
3-
if (name !== "") return { statusCode: 500 };
4-
if (email !== "test@geode-solutions.com") return { statusCode: 500 };
5-
if (launch !== false) return { statusCode: 500 };
6-
return { statusCode: 200 };
5+
return check_recaptcha_params(name, email, launch);
76
};

utils/local.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ async function run_browser(script_name) {
216216
process.env.NUXT_PORT = nuxt_port;
217217
const nuxt_process = spawn("npm", ["run", script_name], {
218218
shell: true,
219+
stdio: "inherit",
219220
});
220221
nuxt_process.stdout.on("data", function (data) {
221222
const output = data.toString();

0 commit comments

Comments
 (0)