reorg getQueryToken, stripQueryToken in utils/utils
This commit is contained in:
parent
8d684bf1ef
commit
53d6b9d704
|
@ -6,6 +6,7 @@ import routes from '../routes';
|
||||||
import Login from '../components/Login';
|
import Login from '../components/Login';
|
||||||
import Layout from "../components/Layout";
|
import Layout from "../components/Layout";
|
||||||
import { DEFAULT_HOST } from '../constants';
|
import { DEFAULT_HOST } from '../constants';
|
||||||
|
import {getQueryToken, stripQueryToken} from '../utils/utils';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
authenticate, fetchCredentials, logout,
|
authenticate, fetchCredentials, logout,
|
||||||
|
@ -20,22 +21,7 @@ import {LIGHT_THEME, DARK_THEME} from '../constants';
|
||||||
|
|
||||||
import { getCredentials, getAuthenticationError, getProcesses, getTheme } from '../reducers/selectors';
|
import { getCredentials, getAuthenticationError, getProcesses, getTheme } from '../reducers/selectors';
|
||||||
|
|
||||||
const qs = require('qs');
|
|
||||||
|
|
||||||
class AppContainer extends Component {
|
class AppContainer extends Component {
|
||||||
getQueryToken() {
|
|
||||||
return qs.parse(this.props.location.search, {ignoreQueryPrefix: true}).token;
|
|
||||||
}
|
|
||||||
|
|
||||||
stripQueryToken(location) {
|
|
||||||
const _location = Object.assign({}, location);
|
|
||||||
_location.search = _location.search.replace(
|
|
||||||
/(\?|&?)(token=[\w-]*)(&?)/,
|
|
||||||
(_, p1, p2, p3) => (p2 ? (p3 === '&' ? p1 : '') : '')
|
|
||||||
);
|
|
||||||
return _location;
|
|
||||||
}
|
|
||||||
|
|
||||||
queryStringAuthenticate() {
|
queryStringAuthenticate() {
|
||||||
if (this.props.credentials.authenticating) {
|
if (this.props.credentials.authenticating) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const Convert = require('ansi-to-html');
|
const Convert = require('ansi-to-html');
|
||||||
|
import qs from 'qs';
|
||||||
|
|
||||||
export function last(array) {
|
export function last(array) {
|
||||||
return array && array.length ? array[array.length - 1] : undefined;
|
return array && array.length ? array[array.length - 1] : undefined;
|
||||||
|
@ -18,4 +19,16 @@ export function hashCode(str) {
|
||||||
export function ansiToHtml(text) {
|
export function ansiToHtml(text) {
|
||||||
const convert = new Convert();
|
const convert = new Convert();
|
||||||
return convert.toHtml(text.replace(/\n/g,'<br>'))
|
return convert.toHtml(text.replace(/\n/g,'<br>'))
|
||||||
|
|
||||||
|
export function getQueryToken(location) {
|
||||||
|
return qs.parse(location.search, {ignoreQueryPrefix: true}).token;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function stripQueryToken(location) {
|
||||||
|
const _location = Object.assign({}, location);
|
||||||
|
_location.search = _location.search.replace(
|
||||||
|
/(\?|&?)(token=[\w-]*)(&?)/,
|
||||||
|
(_, p1, p2, p3) => (p2 ? (p3 === '&' ? p1 : '') : '')
|
||||||
|
);
|
||||||
|
return _location;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue