Skip to content

Commit

Permalink
fixes #223 add X-CSRF-TOKEN to the header to integrate with light-portal
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehu committed Nov 1, 2020
1 parent 41698c1 commit 5e30a65
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-schema-form",
"version": "0.9.9",
"version": "0.9.10",
"description": "React json schema form",
"keywords": [
"json schema",
Expand Down Expand Up @@ -78,6 +78,7 @@
"react-mde": "^11.0.0",
"showdown": "^1.9.1",
"supports-color": "^7.1.0",
"tv4": "^1.3.0"
"tv4": "^1.3.0",
"universal-cookie": "^4.0.4"
}
}
2 changes: 1 addition & 1 deletion src/Markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Markdown = (props) => {
const [selectedTab, setSelectedTab] = useState('write')
const [text, setText] = useState(value)
useEffect(() => {
onChangeValidate({target: {value: text}})
onChangeValidate({ target: { value: text } })
}, [text])
return (
<React.Fragment>
Expand Down
7 changes: 6 additions & 1 deletion src/Taxonomy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import AddBoxIcon from '@material-ui/icons/AddBox'
import FolderIcon from '@material-ui/icons/Folder'
import FolderOpenIcon from '@material-ui/icons/FolderOpen'
import InsertDriveFileIcon from '@material-ui/icons/InsertDriveFile'
import Cookies from 'universal-cookie'
import ComposedComponent from './ComposedComponent'

function Taxonomy(props) {
Expand All @@ -26,7 +27,11 @@ function Taxonomy(props) {
}, [taxonomies])

const fetchCateogry = (url) => {
fetch(url)
const cookies = new Cookies()
const headers = { 'Content-Type': 'application/json' }
if (cookies.get('csrf'))
Object.assign(headers, { 'X-CSRF-TOKEN': cookies.get('csrf') })
fetch(url, { headers, credentials: 'include' })
.then((res) => {
if (res.ok) {
return res.json()
Expand Down
18 changes: 18 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1759,6 +1759,11 @@
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==

"@types/cookie@^0.3.3":
version "0.3.3"
resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.3.3.tgz#85bc74ba782fb7aa3a514d11767832b0e3bc6803"
integrity sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow==

"@types/eslint-visitor-keys@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
Expand Down Expand Up @@ -3483,6 +3488,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba"
integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==

cookie@^0.4.0:
version "0.4.1"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.1.tgz#afd713fe26ebd21ba95ceb61f9a8116e50a537d1"
integrity sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==

copy-concurrently@^1.0.0:
version "1.0.5"
resolved "https://registry.yarnpkg.com/copy-concurrently/-/copy-concurrently-1.0.5.tgz#92297398cae34937fcafd6ec8139c18051f0b5e0"
Expand Down Expand Up @@ -11611,6 +11621,14 @@ unique-slug@^2.0.0:
dependencies:
imurmurhash "^0.1.4"

universal-cookie@^4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/universal-cookie/-/universal-cookie-4.0.4.tgz#06e8b3625bf9af049569ef97109b4bb226ad798d"
integrity sha512-lbRVHoOMtItjWbM7TwDLdl8wug7izB0tq3/YVKhT/ahB4VDvWMyvnADfnJI8y6fSvsjh51Ix7lTGC6Tn4rMPhw==
dependencies:
"@types/cookie" "^0.3.3"
cookie "^0.4.0"

universalify@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
Expand Down

0 comments on commit 5e30a65

Please sign in to comment.