diff --git a/embark-ui/src/containers/AppContainer.js b/embark-ui/src/containers/AppContainer.js index 314684a0e..e47ca54b2 100644 --- a/embark-ui/src/containers/AppContainer.js +++ b/embark-ui/src/containers/AppContainer.js @@ -23,8 +23,12 @@ import { getCredentials, getAuthenticationError, getProcesses, getTheme } from ' const qs = require('qs'); class AppContainer extends Component { + getToken() { + return qs.parse(this.props.location.search, {ignoreQueryPrefix: true}).token; + } + queryStringAuthenticate() { - const token = qs.parse(this.props.location.search, {ignoreQueryPrefix: true}).token; + const token = this.getToken(); if (!token) { return; @@ -50,6 +54,15 @@ class AppContainer extends Component { this.props.authenticate(this.props.credentials.host, this.props.credentials.token); } + if (this.getToken() && this.props.credentials.authenticated) { + const loc = Object.assign({}, this.props.location); + loc.search = loc.search.replace( + /(\?|&?)(token=[\w-]*)(&?)/, + (_, p1, p2, p3) => (p2 ? (p3 === '&' ? p1 : '') : '') + ); + this.props.history.replace(loc); + } + if (this.props.credentials.authenticated && !this.props.initialized) { this.props.fetchProcesses(); this.props.fetchServices();