Sprinkle credentials: same-origin on authenticated fetches

This commit is contained in:
Tom Russell 2018-09-30 20:29:46 +01:00
parent aae5c1ca32
commit 11e93a18b3
3 changed files with 10 additions and 5 deletions

View File

@ -74,7 +74,8 @@ class BuildingEdit extends Component {
body: JSON.stringify(this.state),
headers:{
'Content-Type': 'application/json'
}
},
credentials: 'same-origin'
}).then(
res => res.json()
).then(function(res){

View File

@ -17,7 +17,8 @@ class MyAccountPage extends Component {
this.setState({error: undefined});
fetch('/logout', {
method: 'POST'
method: 'POST',
credentials: 'same-origin'
}).then(
res => res.json()
).then(function(res){
@ -32,7 +33,7 @@ class MyAccountPage extends Component {
}
render() {
if (this.props && this.props.user) {
if (this.props.user && !this.props.user.error) {
return (
<article>
<section className="main-col">

View File

@ -41,14 +41,17 @@ class SignUp extends Component {
body: JSON.stringify(this.state),
headers:{
'Content-Type': 'application/json'
}
},
credentials: 'same-origin'
}).then(
res => res.json()
).then(function(res){
if (res.error) {
this.setState({error: res.error})
} else {
fetch('/users/me').then(
fetch('/users/me', {
credentials: 'same-origin'
}).then(
(res) => res.json()
).then(
(user) => this.props.login(user)