From f3f84961eb9ddf3dacfb3e4bf5c56504303c048f Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 17 Sep 2018 12:54:23 +0200 Subject: redirects work --- app/client/auth/auth.gate.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'app/client/auth/auth.gate.js') diff --git a/app/client/auth/auth.gate.js b/app/client/auth/auth.gate.js index 087dfc6..574feb3 100644 --- a/app/client/auth/auth.gate.js +++ b/app/client/auth/auth.gate.js @@ -4,6 +4,7 @@ import { BrowserRouter, Route, Switch, Redirect, withRouter } from 'react-router import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; +import { history } from '../store' import * as authActions from './auth.actions'; import Login from './login.component'; @@ -44,7 +45,18 @@ class AuthGate extends Component { if (!this.props.auth.initialized) { return
Loading
} - if (this.props.auth.isAuthenticated) return
{this.props.children}
+ if (this.props.auth.isAuthenticated) { + if (this.props.auth.returnTo) { + let { returnTo } = this.props.auth + if (!returnTo || returnTo.match(/(login|logout|signup)/i)) { + returnTo = '/' + } + this.props.actions.setReturnTo(null) + history.push(returnTo) + return
Launching app
+ } + return
{this.props.children}
+ } return } componentDidMount(){ -- cgit v1.2.3-70-g09d2