Skip to content

Commit 30a7c8c

Browse files
authored
fix: fix cookie validation in authentication (#5621)
1 parent 496220a commit 30a7c8c

2 files changed

Lines changed: 28 additions & 19 deletions

File tree

frontend/common/services/useBuildVersion.ts

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,37 @@ export const buildVersionService = service
1212
getBuildVersion: builder.query<Version, Req['getBuildVersion']>({
1313
providesTags: () => [{ id: 'BuildVersion', type: 'BuildVersion' }],
1414
queryFn: async (args, _, _2, baseQuery) => {
15-
const [frontendRes, backendRes] = await Promise.all([
16-
data.get(`/version/`).catch(() => ({})),
17-
data.get(`${Project.api.replace('api/v1/', '')}version/`),
18-
])
15+
try {
16+
const [frontendRes, backendRes] = await Promise.all([
17+
data.get(`/version/`).catch(() => ({})),
18+
data.get(`${Project.api.replace('api/v1/', '')}version/`),
19+
])
1920

20-
const frontend = (frontendRes || {}) as Version['frontend']
21-
const backend =
22-
(backendRes as Version['backend']) || ({} as Version['backend'])
21+
const frontend = (frontendRes || {}) as Version['frontend']
22+
const backend =
23+
(backendRes as Version['backend']) || ({} as Version['backend'])
2324

24-
const tag = backend?.image_tag || defaultVersionTag
25-
const backend_sha = backend?.ci_commit_sha || defaultVersionTag
26-
const frontend_sha = frontend?.ci_commit_sha || defaultVersionTag
25+
const tag = backend?.image_tag || defaultVersionTag
26+
const backend_sha = backend?.ci_commit_sha || defaultVersionTag
27+
const frontend_sha = frontend?.ci_commit_sha || defaultVersionTag
2728

28-
const result: Version = {
29-
backend,
30-
backend_sha,
31-
frontend,
32-
frontend_sha,
33-
tag,
34-
}
29+
const result: Version = {
30+
backend,
31+
backend_sha,
32+
frontend,
33+
frontend_sha,
34+
tag,
35+
}
3536

36-
return { data: result }
37+
return { data: result }
38+
} catch (error) {
39+
return {
40+
error: {
41+
error: error instanceof Error ? error.message : String(error),
42+
status: 'VERSION_FETCH_ERROR',
43+
},
44+
}
45+
}
3746
},
3847
}),
3948
// END OF ENDPOINTS

frontend/web/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (params.token) {
2727
}
2828

2929
// Render the React application to the DOM
30-
const res = Project.cookieAuthEnabled ? 'true' : API.getCookie('t')
30+
const res = API.getCookie('t')
3131

3232
const event = API.getEvent()
3333
if (event) {

0 commit comments

Comments
 (0)