From 17700826eb2e0ea08d25ae4f6e5a49798e478437 Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Sat, 14 May 2016 11:10:08 +0300 Subject: [PATCH] #65: protect user area from guests --- src/routes.js | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/routes.js b/src/routes.js index 2dce36b..a6ab351 100644 --- a/src/routes.js +++ b/src/routes.js @@ -26,28 +26,38 @@ import authFlow from 'services/authFlow'; export default function routesFactory(store) { authFlow.setStore(store); - const onEnter = { + const startAuthFlow = { onEnter: ({location}, replace) => authFlow.handleRequest(location.pathname, replace) }; + const userOnly = { + onEnter: ({location}, replace) => { + const {user} = store.getState(); + + if (user.isGuest) { + replace('/'); + } + } + }; + return ( - + - + - - - - - - - - - + + + + + + + + + - +