From 021f46b9cf7c61efb8d2531694b0a724d6277c3f Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 17 Sep 2018 02:42:57 +0200 Subject: signup --- app/client/auth/auth.actions.js | 9 ++++----- app/client/auth/signup.component.js | 6 +++++- app/client/index.jsx | 17 +++++++++-------- 3 files changed, 18 insertions(+), 14 deletions(-) (limited to 'app/client') diff --git a/app/client/auth/auth.actions.js b/app/client/auth/auth.actions.js index 33af206..c4d9b52 100644 --- a/app/client/auth/auth.actions.js +++ b/app/client/auth/auth.actions.js @@ -46,10 +46,9 @@ export function login(username, password) { .then(data => { console.log(data) dispatch(setCurrentUser(data.user)) - // dispatch(setToken(data.token)) }) .catch(error => { - console.log(error) + console.error(error) dispatch(setError(true)) }) } @@ -62,10 +61,10 @@ export function signup(data) { .then(req => req.json()) .then(data => { console.log(data) - dispatch(login(data.username, data.password)) + dispatch(setCurrentUser(data.user)) }) .catch(error => { - console.log(error) + console.error(error) dispatch(initialized()) }) } @@ -80,7 +79,7 @@ export function checkin() { dispatch(setCurrentUser(data.user)) }) .catch(error => { - console.log(error) + console.error(error) dispatch(initialized()) }) } diff --git a/app/client/auth/signup.component.js b/app/client/auth/signup.component.js index 87e6ac6..4882681 100644 --- a/app/client/auth/signup.component.js +++ b/app/client/auth/signup.component.js @@ -39,7 +39,11 @@ class Signup extends Component { } render(){ if (this.props.auth.isAuthenticated) { - return + let { returnTo } = this.props.auth + if (!returnTo || returnTo.match(/(api|login|logout|signup)/i)) { + returnTo = '/' + } + return } return (
diff --git a/app/client/index.jsx b/app/client/index.jsx index 614bb35..9c18251 100644 --- a/app/client/index.jsx +++ b/app/client/index.jsx @@ -1,6 +1,6 @@ import { h, render } from 'preact' import { Provider } from 'react-redux' -import { BrowserRouter, Route } from 'react-router-dom' +import { BrowserRouter, Switch, Route, Redirect } from 'react-router-dom' // import client from './client' import { store, history } from './store' @@ -24,16 +24,17 @@ const app = ( -
+ - - - + + + {module_list} - - -
+ + } /> +
+
) -- cgit v1.2.3-70-g09d2