Skip to content

Commit 625cf4b

Browse files
authored
refactor: remove CSRF token handling from RequestAQuoteForm and utils (#5346)
1 parent 5c85341 commit 625cf4b

File tree

3 files changed

+1
-28
lines changed

3 files changed

+1
-28
lines changed

src/components/Support/RequestAQuoteForm.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
checkErrors,
1414
defaultValues,
1515
emptyValues,
16-
refreshStudioCSRFToken,
1716
teamSize
1817
} from './utils'
1918
import { studioContactUsApi } from '../../utils/externalUrls'
@@ -116,12 +115,10 @@ const RequestAQuoteForm = ({
116115
}
117116

118117
try {
119-
const csrfToken = await refreshStudioCSRFToken()
120118
const response = await fetch(studioContactUsApi, {
121119
method: `POST`,
122120
headers: {
123-
'Content-Type': `application/json`,
124-
'X-CsrfToken': csrfToken
121+
'Content-Type': `application/json`
125122
},
126123
credentials: `include`,
127124
mode: `cors`,

src/components/Support/utils.tsx

-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { studioRefreshCsfrApi } from '../../utils/externalUrls'
2-
31
export type FormField =
42
| 'name'
53
| 'company'
@@ -82,24 +80,3 @@ export const checkErrors = (
8280

8381
return { hasError, newErrors }
8482
}
85-
86-
function getCookie(name: string) {
87-
let cookieValue = null
88-
if (document.cookie && document.cookie !== ``) {
89-
const cookies = document.cookie.split(`;`)
90-
for (let i = 0; i < cookies.length; i++) {
91-
const cookie = cookies[i].trim()
92-
// Does this cookie string begin with the name we want?
93-
if (cookie.substring(0, name.length + 1) === name + `=`) {
94-
cookieValue = decodeURIComponent(cookie.substring(name.length + 1))
95-
break
96-
}
97-
}
98-
}
99-
return cookieValue
100-
}
101-
102-
export const refreshStudioCSRFToken = async () => {
103-
await fetch(studioRefreshCsfrApi)
104-
return getCookie(`csrftoken`) || ``
105-
}

src/utils/externalUrls.ts

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export const studioUrl = 'https://studio.datachain.ai'
44

55
// Studio API Urls
66
const studioApi = `${studioUrl}/api`
7-
export const studioRefreshCsfrApi = `${studioApi}/refresh-csrf`
87
export const studioContactUsApi = `${studioApi}/contacts`
98

109
// Github Urls

0 commit comments

Comments
 (0)