diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-09-17 12:54:23 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-09-17 12:54:23 +0200 |
| commit | f3f84961eb9ddf3dacfb3e4bf5c56504303c048f (patch) | |
| tree | 7fe27edce878ca6bd11ebe163c034311d57f936f /app/client/auth/auth.gate.js | |
| parent | 15e5df27774fef8d976c74b6ec7bcf8f878e5834 (diff) | |
redirects work
Diffstat (limited to 'app/client/auth/auth.gate.js')
| -rw-r--r-- | app/client/auth/auth.gate.js | 14 |
1 files changed, 13 insertions, 1 deletions
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 <div className='loading'>Loading</div> } - if (this.props.auth.isAuthenticated) return <div>{this.props.children}</div> + 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 <div>Launching app</div> + } + return <div>{this.props.children}</div> + } return <AuthRouter {...this.props} /> } componentDidMount(){ |
