mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-23 13:48:49 +00:00
make token stripping logic reusable
This commit is contained in:
parent
3071c489a7
commit
d02d2f1522
@ -27,6 +27,15 @@ class AppContainer extends Component {
|
|||||||
return qs.parse(this.props.location.search, {ignoreQueryPrefix: true}).token;
|
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;
|
||||||
@ -62,12 +71,7 @@ class AppContainer extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.getQueryToken() && this.props.credentials.authenticated) {
|
if (this.getQueryToken() && this.props.credentials.authenticated) {
|
||||||
const loc = Object.assign({}, this.props.location);
|
this.props.history.replace(this.stripQueryToken(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) {
|
if (this.props.credentials.authenticated && !this.props.initialized) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user