mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
set csrftokens as constants
This commit is contained in:
parent
7da2149e24
commit
ee6d2789ed
@ -146,7 +146,7 @@ let FileUploader = React.createClass({
|
|||||||
session={{
|
session={{
|
||||||
endpoint: AppConstants.serverUrl + 'api/blob/otherdatas/fineuploader_session/',
|
endpoint: AppConstants.serverUrl + 'api/blob/otherdatas/fineuploader_session/',
|
||||||
customHeaders: {
|
customHeaders: {
|
||||||
'X-CSRFToken': getCookie('csrftoken')
|
'X-CSRFToken': getCookie(AppConstants.csrftoken)
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
'pk': this.props.otherData ? this.props.otherData.id : null
|
'pk': this.props.otherData ? this.props.otherData.id : null
|
||||||
@ -159,7 +159,7 @@ let FileUploader = React.createClass({
|
|||||||
signature={{
|
signature={{
|
||||||
endpoint: AppConstants.serverUrl + 's3/signature/',
|
endpoint: AppConstants.serverUrl + 's3/signature/',
|
||||||
customHeaders: {
|
customHeaders: {
|
||||||
'X-CSRFToken': getCookie('csrftoken')
|
'X-CSRFToken': getCookie(AppConstants.csrftoken)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
deleteFile={{
|
deleteFile={{
|
||||||
@ -167,7 +167,7 @@ let FileUploader = React.createClass({
|
|||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
endpoint: AppConstants.serverUrl + 's3/delete',
|
endpoint: AppConstants.serverUrl + 's3/delete',
|
||||||
customHeaders: {
|
customHeaders: {
|
||||||
'X-CSRFToken': getCookie('csrftoken')
|
'X-CSRFToken': getCookie(AppConstants.csrftoken)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
areAssetsDownloadable={true}
|
areAssetsDownloadable={true}
|
||||||
|
@ -162,7 +162,7 @@ let FileUploader = React.createClass({
|
|||||||
signature={{
|
signature={{
|
||||||
endpoint: AppConstants.serverUrl + 's3/signature/',
|
endpoint: AppConstants.serverUrl + 's3/signature/',
|
||||||
customHeaders: {
|
customHeaders: {
|
||||||
'X-CSRFToken': getCookie('csrftoken')
|
'X-CSRFToken': getCookie(AppConstants.csrftoken)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
deleteFile={{
|
deleteFile={{
|
||||||
@ -170,7 +170,7 @@ let FileUploader = React.createClass({
|
|||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
endpoint: AppConstants.serverUrl + 's3/delete',
|
endpoint: AppConstants.serverUrl + 's3/delete',
|
||||||
customHeaders: {
|
customHeaders: {
|
||||||
'X-CSRFToken': getCookie('csrftoken')
|
'X-CSRFToken': getCookie(AppConstants.csrftoken)
|
||||||
}
|
}
|
||||||
}}/>
|
}}/>
|
||||||
);
|
);
|
||||||
|
@ -13,6 +13,8 @@ import FileDragAndDrop from './file_drag_and_drop';
|
|||||||
import GlobalNotificationModel from '../../models/global_notification_model';
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||||
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||||
|
|
||||||
|
import AppConstants from '../../constants/application_constants';
|
||||||
|
|
||||||
var ReactS3FineUploader = React.createClass({
|
var ReactS3FineUploader = React.createClass({
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
@ -146,7 +148,7 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
return {
|
return {
|
||||||
filesToUpload: [],
|
filesToUpload: [],
|
||||||
uploader: new fineUploader.s3.FineUploaderBasic(this.propsToConfig()),
|
uploader: new fineUploader.s3.FineUploaderBasic(this.propsToConfig()),
|
||||||
csrfToken: getCookie('csrftoken')
|
csrfToken: getCookie(AppConstants.csrftoken)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -154,7 +156,7 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
// everytime the csrf cookie is changed we'll need to reinitalize
|
// everytime the csrf cookie is changed we'll need to reinitalize
|
||||||
// fineuploader and update the actual csrf token
|
// fineuploader and update the actual csrf token
|
||||||
componentWillUpdate() {
|
componentWillUpdate() {
|
||||||
let potentiallyNewCSRFToken = getCookie('csrftoken');
|
let potentiallyNewCSRFToken = getCookie(AppConstants.csrftoken);
|
||||||
if(this.state.csrfToken !== potentiallyNewCSRFToken) {
|
if(this.state.csrfToken !== potentiallyNewCSRFToken) {
|
||||||
this.setState({
|
this.setState({
|
||||||
uploader: new fineUploader.s3.FineUploaderBasic(this.propsToConfig()),
|
uploader: new fineUploader.s3.FineUploaderBasic(this.propsToConfig()),
|
||||||
@ -212,7 +214,7 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-CSRFToken': getCookie('csrftoken')
|
'X-CSRFToken': getCookie(AppConstants.csrftoken)
|
||||||
},
|
},
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@ -242,7 +244,7 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-CSRFToken': getCookie('csrftoken')
|
'X-CSRFToken': getCookie(AppConstants.csrftoken)
|
||||||
},
|
},
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
@ -225,7 +225,7 @@ let FileUploader = React.createClass({
|
|||||||
session={{
|
session={{
|
||||||
endpoint: apiUrls.ownership_loans_contract,
|
endpoint: apiUrls.ownership_loans_contract,
|
||||||
customHeaders: {
|
customHeaders: {
|
||||||
'X-CSRFToken': getCookie('csrftoken')
|
'X-CSRFToken': getCookie(AppConstants.csrftoken)
|
||||||
},
|
},
|
||||||
cors: {
|
cors: {
|
||||||
expected: true,
|
expected: true,
|
||||||
@ -235,7 +235,7 @@ let FileUploader = React.createClass({
|
|||||||
signature={{
|
signature={{
|
||||||
endpoint: AppConstants.serverUrl + 's3/signature/',
|
endpoint: AppConstants.serverUrl + 's3/signature/',
|
||||||
customHeaders: {
|
customHeaders: {
|
||||||
'X-CSRFToken': getCookie('csrftoken')
|
'X-CSRFToken': getCookie(AppConstants.csrftoken)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
deleteFile={{
|
deleteFile={{
|
||||||
@ -243,7 +243,7 @@ let FileUploader = React.createClass({
|
|||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
endpoint: AppConstants.serverUrl + 's3/delete',
|
endpoint: AppConstants.serverUrl + 's3/delete',
|
||||||
customHeaders: {
|
customHeaders: {
|
||||||
'X-CSRFToken': getCookie('csrftoken')
|
'X-CSRFToken': getCookie(AppConstants.csrftoken)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
areAssetsDownloadable={true}
|
areAssetsDownloadable={true}
|
||||||
|
@ -14,6 +14,7 @@ let constants = {
|
|||||||
'acl_loan', 'acl_share', 'acl_transfer', 'acl_unconsign', 'acl_unshare', 'acl_view',
|
'acl_loan', 'acl_share', 'acl_transfer', 'acl_unconsign', 'acl_unshare', 'acl_view',
|
||||||
'acl_withdraw_transfer'],
|
'acl_withdraw_transfer'],
|
||||||
|
|
||||||
|
'csrftoken': 'csrftoken',
|
||||||
'subdomains': [
|
'subdomains': [
|
||||||
{
|
{
|
||||||
'subdomain': 'cc',
|
'subdomain': 'cc',
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { argsToQueryParams, getCookie } from '../utils/fetch_api_utils';
|
import { argsToQueryParams, getCookie } from '../utils/fetch_api_utils';
|
||||||
|
import AppConstants from '../constants/application_constants';
|
||||||
|
|
||||||
class UrlMapError extends Error {}
|
class UrlMapError extends Error {}
|
||||||
class ServerError extends Error {}
|
class ServerError extends Error {}
|
||||||
@ -100,7 +100,7 @@ class Requests {
|
|||||||
request(verb, url, options) {
|
request(verb, url, options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
let merged = this._merge(this.httpOptions, options);
|
let merged = this._merge(this.httpOptions, options);
|
||||||
let csrftoken = getCookie('csrftoken');
|
let csrftoken = getCookie(AppConstants.csrftoken);
|
||||||
if (csrftoken) {
|
if (csrftoken) {
|
||||||
merged.headers['X-CSRFToken'] = csrftoken;
|
merged.headers['X-CSRFToken'] = csrftoken;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user