Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

Token validation (#4)

Giuseppe Macrìb17c4c9f885d
diff --git a/examples/demo-app/src/actions.js b/examples/demo-app/src/actions.js
index 07adb05b2..2bc934fba 100644
--- a/examples/demo-app/src/actions.js
+++ b/examples/demo-app/src/actions.js
@@ -63,8 +63,9 @@ export function setLoadingMapStatus(isMapLoading) {
}
export function loadSampleMap(sample) {
- return (dispatch) => {
- dispatch(push(`/demo/${sample.id}`));
+ return (dispatch, getState) => {
+ const {routing} = getState();
+ dispatch(push(`/demo/${sample.id}${routing.locationBeforeTransitions.search}`));
dispatch(loadRemoteMap(sample));
dispatch(setLoadingMapStatus(true));
};
diff --git a/examples/demo-app/src/constants/default-settings.js b/examples/demo-app/src/constants/default-settings.js
index 0c8e7ff83..2b9093512 100644
--- a/examples/demo-app/src/constants/default-settings.js
+++ b/examples/demo-app/src/constants/default-settings.js
@@ -22,6 +22,10 @@
and segments both use queryRunner */
import keyMirror from 'keymirror';
+export const ASSETS_URL = 'https://d1a3f4spazzrp4.cloudfront.net/kepler.gl/';
+
+export const DATA_URL = 'https://raw.githubusercontent.com/uber-web/kepler.gl-data/master/';
+
export const QUERY_TYPES = keyMirror({
file: null,
sample: null
@@ -66,5 +70,3 @@ export const LOADING_METHODS = [
];
export const DEFAULT_LOADING_METHOD = LOADING_METHODS[0];
-
-export const ASSETS_URL = 'https://d1a3f4spazzrp4.cloudfront.net/kepler.gl/';
diff --git a/examples/demo-app/src/constants/sample-maps.js b/examples/demo-app/src/constants/sample-maps.js
index 69efb70da..ffe6043cb 100644
--- a/examples/demo-app/src/constants/sample-maps.js
+++ b/examples/demo-app/src/constants/sample-maps.js
@@ -18,8 +18,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-const DATA_URL = 'https://raw.githubusercontent.com/macrigiuseppe/kepler.gl-data/master/';
+import {DATA_URL} from './default-settings';
+
/*
* If you want to add more samples, feel free to edit the json file on github kepler.gl data repo
*/
-export const MAP_CONFIG_URL = `${DATA_URL}/samples.json`;
+export const MAP_CONFIG_URL = `${DATA_URL}samples.json`;
diff --git a/src/components/common/icons/left-arrow.js b/src/components/common/icons/left-arrow.js
index c68a94fa4..9c4b3c911 100644
--- a/src/components/common/icons/left-arrow.js
+++ b/src/components/common/icons/left-arrow.js
@@ -1,3 +1,23 @@
+// Copyright (c) 2018 Uber Technologies, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
import PropTypes from 'prop-types';
import React from 'react';
import Base from './base';
diff --git a/website/src/beta/tokens.js b/website/src/beta/tokens.js
new file mode 100644
index 000000000..460c2e31c
--- /dev/null
+++ b/website/src/beta/tokens.js
@@ -0,0 +1,66 @@
+export const tokens = [
+ '028bea5792f7facb0bf85ba908dfe98b',
+ '03cf23c3f43882b1c436380d07a97ac5',
+ '0a5442472f566982ecaba9b86c5948f7',
+ '0ff2119d7c53bd1bae8d2e360eccd760',
+ '129a8eb7c264689ce6655ee7bc52fa93',
+ '12f5fd7c05600d298ab518c14492c514',
+ '1380a29483c2b180299a3efc89335135',
+ '1d950601c6b3891a8cfa3c6ddc7a83eb',
+ '21938123891981c4507a70bc3f8177d5',
+ '24ab22bc083f24e6581b6784ee4141a9',
+ '24ab22bc083f24e6581b6784ee4141a9',
+ '255b7237fa19ce2a30be09c9bd717753',
+ '2b23341d2ea7ea696d099abf287a5fc8',
+ '313086283a1bdeffdaf78efeac9a611e',
+ '35f4f777e16fa974ed897bc12005a284',
+ '361a1aab3f18c5343f34cec6efcacb31',
+ '388b42a403fbd6888ad16f690e93c8de',
+ '3b15e033b3a398fe417a7d988afaa64c',
+ '3c45c86ac6f84b0b496b44cbec563158',
+ '410e2babf8be6a494dc4d2417b04dbb2',
+ '41dabc26c6da6684be2e0f6e0c75f768',
+ '474d6b6f3a35e28fb0ae505918ca6a04',
+ '4f54aec13622ab5987bdd9017b40ea32',
+ '58b16417808c670af2aa457edb988921',
+ '5e2af057e5805cbd8fbaf84f2d31d545',
+ '68e01cc42098a5a984017aee45f57223',
+ '6a84a4627234297e45081d00039b7999',
+ '6a84a4627234297e45081d00039b7999',
+ '6cbea41e58fe554a8c34ccda789b6255',
+ '7709d449d7de2dea634b84e29d9f25bc',
+ '7d7cb5cfc949cdd7e29b9db5d7641b8f',
+ '7ee4046defb8b843e9a955d3b149b594',
+ '82d1d4de750d20b3199ef01350941e7b',
+ '85ae122facdaf9b07e0616cb10984c11',
+ '8a77e9073b3eda0b61406aec8c960d2b',
+ '8db7971698f7c108ecea337e48d57f1e',
+ '9892285a2f651b1ae836cfffc24ae4f8',
+ '9bc3f1e5f195668c235f312b5189634a',
+ 'a148885f42184f37be7dde3440712625',
+ 'a5ea3a3b5adc78b6436cc9552cc8c3f3',
+ 'a998b11476d11cf64a0f1419e0356139',
+ 'ae525756dcf1ffcbaa22d7e690a31858',
+ 'aec282d51ec9c607a55c77c406034950',
+ 'bbabbe69157e451f1954877d1b06616a',
+ 'c2a3a71a5b4d6d41919f07507328ba1f',
+ 'c49dee036611338fb79bdc1fcf98d19e',
+ 'c52d941f52e3774b6f760ead132deccd',
+ 'c6b5097bed95ff2b2ff9377926977ac3',
+ 'cd2853068627a6be0644332225c88fbc',
+ 'cf783f79cd7c98cfde95a9854b6be4ad',
+ 'd082077878e540bcf41da4def5c596e5',
+ 'd5ffb69d36b788b5ce6408297e4a9523',
+ 'd612e176cb18a5190a722dc0313cb583',
+ 'dc7339fdcf0d7cbb7ab156ed6c1719b3',
+ 'dd1e603035457abc2f10d752897c8428',
+ 'e0cf455ad112c8db86bd578bcc72c7ca',
+ 'e0fddcc50ec7eee5b4eeb40e88c5641d',
+ 'e9f4832e5fff6e8688fd0749979742fe',
+ 'ea7f7f58cc60bc5d07240be637af6ea4',
+ 'ec2874375c7c2a9b584bedcc1e03498b',
+ 'ef067cf09ffd3cc8f069bacec73c8202',
+ 'f64b30b6d78d505f9bc9cd958fa7d306',
+ 'f96cf9be860278c622bb76ce8a042327',
+ 'fbc7d59193a015987f80b93965ffa8ea'
+];
diff --git a/website/src/routes.js b/website/src/routes.js
index 7245d34aa..b7f765f74 100644
--- a/website/src/routes.js
+++ b/website/src/routes.js
@@ -27,12 +27,22 @@ import Home from './components/home';
import App from './components/app';
import Demo from '../../examples/demo-app/src/app';
+// Token
+// TODO: remove this when beta is over
+import {tokens} from './beta/tokens';
+
+const checkAccessCode = ({location: {pathname, query}}, replace) => {
+ if (pathname.includes('/demo') && (!query.token || !tokens.includes(query.token))) {
+ replace('/');
+ }
+};
+
// eslint-disable-next-line react/display-name
export default () => (
<Router history={syncHistoryWithStore(hashHistory, store)}>
<Route path="/" component={App}>
<IndexRoute component={Home} />
- <Route path="demo(/:id)" component={Demo} />
+ <Route path="demo(/:id)" component={Demo} onEnter={checkAccessCode}/>
</Route>
</Router>
);