summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-09-17 13:24:41 +0200
committerJules Laplace <julescarbon@gmail.com>2018-09-17 13:24:41 +0200
commit3043751ba11a38ebd9f03416fd7f4600dae41f1a (patch)
treebef7fdef47182814a10c73b2f6799c46e8462b58
parentf3f84961eb9ddf3dacfb3e4bf5c56504303c048f (diff)
production routing shit
-rw-r--r--app/client/auth/auth.gate.js4
-rw-r--r--app/client/auth/auth.reducer.js1
-rw-r--r--app/client/index.jsx25
-rw-r--r--app/server/util/auth.js8
4 files changed, 23 insertions, 15 deletions
diff --git a/app/client/auth/auth.gate.js b/app/client/auth/auth.gate.js
index 574feb3..2bbbc6d 100644
--- a/app/client/auth/auth.gate.js
+++ b/app/client/auth/auth.gate.js
@@ -43,18 +43,22 @@ class AuthRouter extends Component {
class AuthGate extends Component {
render(){
if (!this.props.auth.initialized) {
+ console.log('loading auth')
return <div className='loading'>Loading</div>
}
if (this.props.auth.isAuthenticated) {
+ console.log('authenticated...')
if (this.props.auth.returnTo) {
let { returnTo } = this.props.auth
if (!returnTo || returnTo.match(/(login|logout|signup)/i)) {
returnTo = '/'
}
+ console.log('history.push', returnTo)
this.props.actions.setReturnTo(null)
history.push(returnTo)
return <div>Launching app</div>
}
+ console.log('rendering as normal')
return <div>{this.props.children}</div>
}
return <AuthRouter {...this.props} />
diff --git a/app/client/auth/auth.reducer.js b/app/client/auth/auth.reducer.js
index 80b1ec5..a56f94a 100644
--- a/app/client/auth/auth.reducer.js
+++ b/app/client/auth/auth.reducer.js
@@ -11,6 +11,7 @@ const authInitialState = {
}
const auth = (state = authInitialState, action) => {
+ console.log(action)
switch(action.type) {
case types.auth.set_token:
return {
diff --git a/app/client/index.jsx b/app/client/index.jsx
index 33e4148..0b0ed05 100644
--- a/app/client/index.jsx
+++ b/app/client/index.jsx
@@ -19,20 +19,25 @@ const module_list = Object.keys(modules).map(name => {
)
})
+const ModuleRouter = () => {
+ return (
+ <Switch></Switch>
+ )
+}
+
const app = (
<Provider store={store}>
<Auth.Gate>
<BrowserRouter>
- <div>
- <Switch>
- <Route exact path='/' component={Dashboard} />
- <Route exact path='/system/' component={System} />
- <Route exact path='/dashboard/' component={Dashboard} />
- {module_list}
- <Route exact path='/logout/' component={Auth.Logout} />
- <Redirect from='/login/' to='/' />
- <Redirect from='/signup/' to='/' />
- </Switch>
+ <div className='everybody'>
+ <Route path='/' children={(props) => <div>{console.log(props.location.pathname)}</div>} />
+ <Route exact path='/system' component={System} />
+ <Route exact path='/dashboard' component={Dashboard} />
+ <Route exact path='/logout' component={Auth.Logout} />
+ <Route exact path='/login' component={() => { console.log('pziss'); <Redirect to='/' /> }} />
+ <Route exact path='/signup' component={() => { console.log('pziss'); <Redirect to='/' /> }} />
+ {module_list}
+ <Route exact path='/' component={Dashboard} />
<Route path='/' component={Header} />
</div>
</BrowserRouter>
diff --git a/app/server/util/auth.js b/app/server/util/auth.js
index e7ee275..098af5d 100644
--- a/app/server/util/auth.js
+++ b/app/server/util/auth.js
@@ -52,7 +52,6 @@ export function getUserByUsername(username) {
export function checkIfUserExists(req, res, next) {
getUserByUsername(req.body.username)
.then((user) => {
- console.log('gotta user?', !!user);
user ? res.json({ error: "user exists" }) : next()
}).catch(err => {
console.error('error', err)
@@ -88,7 +87,7 @@ export function createUser(req, res, next) {
}
userModel.create(data)
.then(user => {
- console.log('created userrrrr', user)
+ console.log('created user', username)
req.login(user, err => {
console.log(err)
err ? next(err) : next()
@@ -100,7 +99,6 @@ export function createUser(req, res, next) {
}
export function login(req, res) {
- console.log(req.user)
if (req.isAuthenticated()) {
let returnTo = req.session.returnTo
delete req.session.returnTo
@@ -156,7 +154,7 @@ export function verifyLocalUser(username, password, done) {
// handle passwords!!
getUserByUsername(username)
.then(user => {
- console.log(user)
+ // console.log(user)
// if (err) { return done(err) }
if (! user) { return done("no user") }
if (! user || !validPassword(user, password)) {
@@ -167,7 +165,7 @@ export function verifyLocalUser(username, password, done) {
}
export function checkin(req, res) {
- console.log(req.user)
+ console.log('checked in', req.user.username)
res.json({ user: sanitizeUser(req.user) })
}