diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-09-17 01:57:44 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-09-17 01:57:44 +0200 |
| commit | 7ef59901e08b6610f134c696876695cf52061f48 (patch) | |
| tree | edde6f9ca29ec2f804c3300402011536f8156f1e /public/bundle.js | |
| parent | d2b4aaf625f10c659614d7326d8dc3e2e31ae0f3 (diff) | |
redirection
Diffstat (limited to 'public/bundle.js')
| -rw-r--r-- | public/bundle.js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/public/bundle.js b/public/bundle.js index 5c65ffb..d6adf97 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -1999,7 +1999,8 @@ function login(username, password) { return req.json(); }).then(function (data) { console.log(data); - dispatch(setToken(data.token)); + dispatch(setCurrentUser(data)); + // dispatch(setToken(data.token)) dispatch(checkin()); }).catch(function (error) { console.log(error); @@ -2023,7 +2024,7 @@ function signup(data) { }; } -function checkin(history) { +function checkin() { return function (dispatch) { dispatch(loading()); fetch(api.checkin, (0, _crud.put)({})).then(function (req) { @@ -2034,7 +2035,6 @@ function checkin(history) { console.log('set current user'); }).catch(function (error) { console.log(error); - // history.go('/login') dispatch(initialized(true)); }); }; @@ -2108,6 +2108,8 @@ var AuthRouter = function (_Component) { _createClass(AuthRouter, [{ key: 'render', value: function render() { + var _this2 = this; + return (0, _preact.h)( _reactRouterDom.BrowserRouter, null, @@ -2122,8 +2124,8 @@ var AuthRouter = function (_Component) { (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/login', component: _login2.default }), (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/logout', component: _logout2.default }), (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/signup', component: _signup2.default }), - (0, _preact.h)(_reactRouterDom.Route, { component: function component() { - props.actions.setReturnTo(props.location.pathname); + (0, _preact.h)(_reactRouterDom.Route, { component: function component(props) { + _this2.props.actions.setReturnTo(props.location.pathname); return (0, _preact.h)(_reactRouterDom.Redirect, { to: '/login' }); } }) ) @@ -2416,7 +2418,7 @@ var Login = function (_Component) { key: 'render', value: function render() { if (this.props.auth.isAuthenticated) { - return (0, _preact.h)(_reactRouterDom.Redirect, { to: '/' }); + return (0, _preact.h)(_reactRouterDom.Redirect, { to: this.props.auth.returnTo || '/' }); } return (0, _preact.h)( 'form', @@ -2660,7 +2662,7 @@ var Signup = function (_Component) { key: 'render', value: function render() { if (this.props.auth.isAuthenticated) { - return (0, _preact.h)(_reactRouterDom.Redirect, { to: '/' }); + return (0, _preact.h)(_reactRouterDom.Redirect, { to: this.props.auth.returnTo || '/' }); } return (0, _preact.h)( 'form', |
