feat(cockpit): enable query param authentication in development mode

Prior to this commit it wasn't possible to authenticate using the
`token` query param as the `host` used for authentication doesn't
match the one of the Embark host.
This commit is contained in:
Pascal Precht 2018-10-18 14:50:35 +02:00
parent ff0d7d20df
commit 8562a3f6c8
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
3 changed files with 4 additions and 3 deletions

View File

@ -6,3 +6,4 @@ export const DEPLOYMENT_PIPELINES = {
injectedWeb3: 'injectedWeb3',
embark: 'embark'
}
export const DEFAULT_HOST = 'localhost:8000';

View File

@ -5,6 +5,7 @@ import {withRouter} from "react-router-dom";
import routes from '../routes';
import Login from '../components/Login';
import Layout from "../components/Layout";
import { DEFAULT_HOST } from '../constants';
import {
authenticate, fetchCredentials, logout,
@ -33,7 +34,7 @@ class AppContainer extends Component {
return;
}
const token = qs.parse(this.props.location.search, {ignoreQueryPrefix: true}).token;
const host = window.location.host;
const host = process.env.NODE_ENV === 'development' ? DEFAULT_HOST : window.location.host;
if (token === this.props.credentials.token && this.props.credentials.host === host) {
return;
}

View File

@ -3,11 +3,10 @@ import {REQUEST, SUCCESS, FAILURE, CONTRACT_COMPILE, FILES, LOGOUT, AUTHENTICATE
FETCH_CREDENTIALS, UPDATE_BASE_ETHER, CHANGE_THEME, FETCH_THEME, EXPLORER_SEARCH,
SIGN_MESSAGE, VERIFY_MESSAGE, TOGGLE_BREAKPOINT,
UPDATE_DEPLOYMENT_PIPELINE, WEB3_CONNECT, WEB3_DEPLOY, WEB3_ESTIMAGE_GAS} from "../actions";
import {EMBARK_PROCESS_NAME, DARK_THEME, DEPLOYMENT_PIPELINES} from '../constants';
import {EMBARK_PROCESS_NAME, DARK_THEME, DEPLOYMENT_PIPELINES, DEFAULT_HOST} from '../constants';
const BN_FACTOR = 10000;
const VOID_ADDRESS = '0x0000000000000000000000000000000000000000';
const DEFAULT_HOST = 'localhost:8000';
const MAX_ELEMENTS = 200;
const entitiesDefaultState = {