1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 01:25:17 +01:00

set csrftokens as constants

This commit is contained in:
Tim Daubenschütz 2015-07-16 18:17:45 +02:00
parent 7da2149e24
commit ee6d2789ed
6 changed files with 17 additions and 14 deletions

View File

@ -146,7 +146,7 @@ let FileUploader = React.createClass({
session={{
endpoint: AppConstants.serverUrl + 'api/blob/otherdatas/fineuploader_session/',
customHeaders: {
'X-CSRFToken': getCookie('csrftoken')
'X-CSRFToken': getCookie(AppConstants.csrftoken)
},
params: {
'pk': this.props.otherData ? this.props.otherData.id : null
@ -159,7 +159,7 @@ let FileUploader = React.createClass({
signature={{
endpoint: AppConstants.serverUrl + 's3/signature/',
customHeaders: {
'X-CSRFToken': getCookie('csrftoken')
'X-CSRFToken': getCookie(AppConstants.csrftoken)
}
}}
deleteFile={{
@ -167,7 +167,7 @@ let FileUploader = React.createClass({
method: 'DELETE',
endpoint: AppConstants.serverUrl + 's3/delete',
customHeaders: {
'X-CSRFToken': getCookie('csrftoken')
'X-CSRFToken': getCookie(AppConstants.csrftoken)
}
}}
areAssetsDownloadable={true}

View File

@ -162,7 +162,7 @@ let FileUploader = React.createClass({
signature={{
endpoint: AppConstants.serverUrl + 's3/signature/',
customHeaders: {
'X-CSRFToken': getCookie('csrftoken')
'X-CSRFToken': getCookie(AppConstants.csrftoken)
}
}}
deleteFile={{
@ -170,7 +170,7 @@ let FileUploader = React.createClass({
method: 'DELETE',
endpoint: AppConstants.serverUrl + 's3/delete',
customHeaders: {
'X-CSRFToken': getCookie('csrftoken')
'X-CSRFToken': getCookie(AppConstants.csrftoken)
}
}}/>
);

View File

@ -13,6 +13,8 @@ import FileDragAndDrop from './file_drag_and_drop';
import GlobalNotificationModel from '../../models/global_notification_model';
import GlobalNotificationActions from '../../actions/global_notification_actions';
import AppConstants from '../../constants/application_constants';
var ReactS3FineUploader = React.createClass({
propTypes: {
@ -146,7 +148,7 @@ var ReactS3FineUploader = React.createClass({
return {
filesToUpload: [],
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
// fineuploader and update the actual csrf token
componentWillUpdate() {
let potentiallyNewCSRFToken = getCookie('csrftoken');
let potentiallyNewCSRFToken = getCookie(AppConstants.csrftoken);
if(this.state.csrfToken !== potentiallyNewCSRFToken) {
this.setState({
uploader: new fineUploader.s3.FineUploaderBasic(this.propsToConfig()),
@ -212,7 +214,7 @@ var ReactS3FineUploader = React.createClass({
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-CSRFToken': getCookie('csrftoken')
'X-CSRFToken': getCookie(AppConstants.csrftoken)
},
credentials: 'include',
body: JSON.stringify({
@ -242,7 +244,7 @@ var ReactS3FineUploader = React.createClass({
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-CSRFToken': getCookie('csrftoken')
'X-CSRFToken': getCookie(AppConstants.csrftoken)
},
credentials: 'include',
body: JSON.stringify({

View File

@ -225,7 +225,7 @@ let FileUploader = React.createClass({
session={{
endpoint: apiUrls.ownership_loans_contract,
customHeaders: {
'X-CSRFToken': getCookie('csrftoken')
'X-CSRFToken': getCookie(AppConstants.csrftoken)
},
cors: {
expected: true,
@ -235,7 +235,7 @@ let FileUploader = React.createClass({
signature={{
endpoint: AppConstants.serverUrl + 's3/signature/',
customHeaders: {
'X-CSRFToken': getCookie('csrftoken')
'X-CSRFToken': getCookie(AppConstants.csrftoken)
}
}}
deleteFile={{
@ -243,7 +243,7 @@ let FileUploader = React.createClass({
method: 'DELETE',
endpoint: AppConstants.serverUrl + 's3/delete',
customHeaders: {
'X-CSRFToken': getCookie('csrftoken')
'X-CSRFToken': getCookie(AppConstants.csrftoken)
}
}}
areAssetsDownloadable={true}

View File

@ -14,6 +14,7 @@ let constants = {
'acl_loan', 'acl_share', 'acl_transfer', 'acl_unconsign', 'acl_unshare', 'acl_view',
'acl_withdraw_transfer'],
'csrftoken': 'csrftoken',
'subdomains': [
{
'subdomain': 'cc',

View File

@ -1,7 +1,7 @@
'use strict';
import { argsToQueryParams, getCookie } from '../utils/fetch_api_utils';
import AppConstants from '../constants/application_constants';
class UrlMapError extends Error {}
class ServerError extends Error {}
@ -100,7 +100,7 @@ class Requests {
request(verb, url, options) {
options = options || {};
let merged = this._merge(this.httpOptions, options);
let csrftoken = getCookie('csrftoken');
let csrftoken = getCookie(AppConstants.csrftoken);
if (csrftoken) {
merged.headers['X-CSRFToken'] = csrftoken;
}