summaryrefslogtreecommitdiff
path: root/app/client/auth/auth.gate.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/client/auth/auth.gate.js')
-rw-r--r--app/client/auth/auth.gate.js14
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(){