From 18f3b5115375c5ab3ec0170382496786c5184b68 Mon Sep 17 00:00:00 2001 From: diminator Date: Thu, 2 Jul 2015 11:54:33 +0200 Subject: [PATCH] fineuploader session with cors --- js/components/ascribe_forms/form.js | 4 +- js/components/edition.js | 4 ++ js/components/settings_container.js | 64 ++++++++++++++++++++++++----- js/constants/api_urls.js | 1 + js/fetchers/ownership_fetcher.js | 11 +---- js/utils/requests.js | 4 +- 6 files changed, 65 insertions(+), 23 deletions(-) diff --git a/js/components/ascribe_forms/form.js b/js/components/ascribe_forms/form.js index e6db5405..828e95fe 100644 --- a/js/components/ascribe_forms/form.js +++ b/js/components/ascribe_forms/form.js @@ -110,8 +110,8 @@ let Form = React.createClass({ buttons = (

- - + +

); diff --git a/js/components/edition.js b/js/components/edition.js index 2776a865..a68d7ea1 100644 --- a/js/components/edition.js +++ b/js/components/edition.js @@ -555,6 +555,10 @@ let FileUploader = React.createClass({ }, params: { 'pk': this.props.edition.other_data ? this.props.edition.other_data.id : null + }, + cors: { + expected: true, + sendCredentials: true } }} areAssetsDownloadable={true} diff --git a/js/components/settings_container.js b/js/components/settings_container.js index 2a6af764..dbb19124 100644 --- a/js/components/settings_container.js +++ b/js/components/settings_container.js @@ -15,6 +15,8 @@ import ApplicationStore from '../stores/application_store'; import GlobalNotificationModel from '../models/global_notification_model'; import GlobalNotificationActions from '../actions/global_notification_actions'; +import ReactS3FineUploader from './ascribe_uploader/react_s3_fine_uploader'; + import CollapsibleParagraph from './ascribe_collapsible/collapsible_paragraph'; import Form from './ascribe_forms/form'; import Property from './ascribe_forms/property'; @@ -22,6 +24,7 @@ import Property from './ascribe_forms/property'; import apiUrls from '../constants/api_urls'; import AppConstants from '../constants/application_constants'; +import { getCookie } from '../utils/fetch_api_utils'; let SettingsContainer = React.createClass({ mixins: [Router.Navigation], @@ -30,8 +33,11 @@ let SettingsContainer = React.createClass({ return (
- + + +
+
); } @@ -172,19 +178,57 @@ let BitcoinWalletSettings = React.createClass({ } }); -let ContractSettings = React.createClass({ - - propTypes: { - currentUser: React.PropTypes.object - }, +let LoanContractSettings = React.createClass({ render() { return ( -
-
Username: {this.props.currentUser.username}
-
Email: {this.props.currentUser.email}
-
+ + + + ); + } +}); + +let FileUploader = React.createClass({ + propTypes: { + }, + + render() { + return ( +
+ + + +
+
); } }); diff --git a/js/constants/api_urls.js b/js/constants/api_urls.js index 4952fc44..de8d4abf 100644 --- a/js/constants/api_urls.js +++ b/js/constants/api_urls.js @@ -23,6 +23,7 @@ let apiUrls = { 'ownership_loans': AppConstants.apiEndpoint + 'ownership/loans/', 'ownership_loans_confirm': AppConstants.apiEndpoint + 'ownership/loans/confirm/', 'ownership_loans_deny': AppConstants.apiEndpoint + 'ownership/loans/deny/', + 'ownership_loans_contract': AppConstants.apiEndpoint + 'ownership/loans/contract/', 'ownership_shares': AppConstants.apiEndpoint + 'ownership/shares/', 'ownership_transfers': AppConstants.apiEndpoint + 'ownership/transfers/', 'ownership_transfers_withdraw': AppConstants.apiEndpoint + 'ownership/transfers/withdraw/', diff --git a/js/fetchers/ownership_fetcher.js b/js/fetchers/ownership_fetcher.js index 57cef4b9..b84884e8 100644 --- a/js/fetchers/ownership_fetcher.js +++ b/js/fetchers/ownership_fetcher.js @@ -1,7 +1,6 @@ 'use strict'; -import fetch from 'isomorphic-fetch'; - +import requests from '../utils/requests'; import AppConstants from '../constants/application_constants'; @@ -11,13 +10,7 @@ let OwnershipFetcher = { * If no arg is supplied, load the current user */ fetchLoanContract(email) { - return fetch(AppConstants.baseUrl + 'ownership/loans/contract/?loanee=' + email, { - headers: { - 'Authorization': 'Basic ' + AppConstants.debugCredentialBase64 - } - }).then( - (res) => res.json() - ); + return requests.get(AppConstants.apiEndpoint + 'ownership/loans/contract/?loanee=' + email); } }; diff --git a/js/utils/requests.js b/js/utils/requests.js index 7e42dfee..40c24058 100644 --- a/js/utils/requests.js +++ b/js/utils/requests.js @@ -44,10 +44,10 @@ class Requests { } handleAPIError(json) { - if (!json.success) { + if (json.success === false) { let error = new APIError(); error.json = json; - console.error(new Error('The \'success\' property is missing in the server\'s response.')); + //console.error(new Error('The \'success\' property is missing in the server\'s response.')); throw error; } return json;