Skip to content

Commit 62bebac

Browse files
Merge pull request #185 from Geode-solutions/fix/captcha_on_desktop
fix(captcha): patch validated on desktop mode
2 parents 8986f1c + 58a56f5 commit 62bebac

25 files changed

+19320
-122
lines changed

.github/workflows/CICD.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
uses: actions/checkout@v4
1212
- name: Unit tests
1313
run: |
14-
npm i
14+
npm ci
1515
npm run test
1616
1717
build:

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ logs
2626
.pytest_cache
2727
__snapshots__
2828
coverage
29-
package-lock.json
29+
# package-lock.json

components/FileUploader.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
await Promise.all(promise_array)
8181
files_uploaded.value = true
8282
emit("files_uploaded", internal_files.value)
83+
8384
toggle_loading()
8485
}
8586

components/ObjectSelector.vue

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,14 @@
7272
var promise_array = []
7373
for (const filename of filenames) {
7474
const params = { filename, supported_feature }
75-
const promise = new Promise((resolve, reject) => {
76-
api_fetch(
77-
{ schema, params },
78-
{
79-
request_error_function: () => {
80-
reject()
81-
},
82-
response_function: (response) => {
83-
resolve(response._data.allowed_objects)
84-
},
85-
response_error_function: () => {
86-
reject()
87-
},
88-
},
89-
)
90-
})
75+
const promise = api_fetch({ schema, params })
9176
promise_array.push(promise)
9277
}
93-
const values = await Promise.all(promise_array)
78+
const responses = await Promise.all(promise_array)
79+
let values = []
80+
for (const response of responses) {
81+
values.push(response.data.value.allowed_objects)
82+
}
9483
const all_keys = [...new Set(values.flatMap((value) => Object.keys(value)))]
9584
const common_keys = all_keys.filter(
9685
(i) => !values.some((j) => !Object.keys(j).includes(i)),
@@ -119,7 +108,6 @@
119108
emit("increment_step")
120109
}
121110
}
122-
123111
await get_allowed_objects()
124112
</script>
125113

components/Recaptcha.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
onMounted(() => {
2323
if (process.client) {
2424
const config = useRuntimeConfig()
25-
if (config.public.NODE_ENV !== "production") {
25+
if (config.public.NODE_ENV !== "production" || !infra_store.is_cloud) {
2626
infra_store.$patch({ is_captcha_validated: true })
2727
}
2828
}

composables/api_fetch.js

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,46 +29,41 @@ export function api_fetch(
2929
if (schema.max_retry) {
3030
request_options.max_retry = schema.max_retry
3131
}
32-
return new Promise((resolve, reject) => {
33-
useFetch(schema.$id, {
34-
baseURL: geode_store.base_url,
35-
...request_options,
36-
async onRequestError({ error }) {
32+
return useFetch(schema.$id, {
33+
baseURL: geode_store.base_url,
34+
...request_options,
35+
async onRequestError({ error }) {
36+
await geode_store.stop_request()
37+
await feedback_store.add_error(
38+
error.code,
39+
schema.$id,
40+
error.message,
41+
error.stack,
42+
)
43+
if (request_error_function) {
44+
await request_error_function(error)
45+
}
46+
},
47+
async onResponse({ response }) {
48+
if (response.ok) {
3749
await geode_store.stop_request()
38-
await feedback_store.add_error(
39-
error.code,
40-
schema.$id,
41-
error.message,
42-
error.stack,
43-
)
44-
if (request_error_function) {
45-
await request_error_function(error)
50+
if (response_function) {
51+
await response_function(response)
4652
}
47-
reject(error)
48-
},
49-
async onResponse({ response }) {
50-
if (response.ok) {
51-
await geode_store.stop_request()
52-
if (response_function) {
53-
await response_function(response)
54-
}
55-
resolve(response)
56-
}
57-
},
58-
async onResponseError({ response }) {
59-
await geode_store.stop_request()
60-
await feedback_store.add_error(
61-
response.status,
62-
schema.$id,
63-
response._data.name,
64-
response._data.description,
65-
)
66-
if (response_error_function) {
67-
await response_error_function(response)
68-
}
69-
reject(response)
70-
},
71-
})
53+
}
54+
},
55+
async onResponseError({ response }) {
56+
await geode_store.stop_request()
57+
await feedback_store.add_error(
58+
response.status,
59+
schema.$id,
60+
response._data.name,
61+
response._data.description,
62+
)
63+
if (response_error_function) {
64+
await response_error_function(response)
65+
}
66+
},
7267
})
7368
}
7469

composables/upload_file.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import { useAppConfig } from "nuxt/app"
2+
13
export async function upload_file(
24
{ route, file },
35
{ request_error_function, response_function, response_error_function } = {},
46
) {
7+
console.log("upload_file", route, file)
58
const feedback_store = use_feedback_store()
69
const geode_store = use_geode_store()
710
if (!(file instanceof File)) {
@@ -17,17 +20,22 @@ export async function upload_file(
1720
}
1821

1922
geode_store.start_request()
20-
return useFetch(route, {
23+
return $fetch(route, {
2124
baseURL: geode_store.base_url,
2225
...request_options,
26+
onRequest({ request }) {
27+
console.log("onRequest", request)
28+
},
2329
onRequestError({ error }) {
30+
console.log("onRequestError", error)
2431
geode_store.stop_request()
2532
feedback_store.add_error(error.code, route, error.message, error.stack)
2633
if (request_error_function) {
2734
request_error_function(error)
2835
}
2936
},
3037
onResponse({ response }) {
38+
console.log("onResponse", response)
3139
if (response.ok) {
3240
geode_store.stop_request()
3341
if (response_function) {
@@ -36,6 +44,7 @@ export async function upload_file(
3644
}
3745
},
3846
onResponseError({ response }) {
47+
console.log("onResponseError", response)
3948
geode_store.stop_request()
4049
feedback_store.add_error(
4150
response.status,

eslint.config.cjs

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

0 commit comments

Comments
 (0)