diff --git a/frontend/src/Editor/Editor.jsx b/frontend/src/Editor/Editor.jsx index a83a50131a..364949a96f 100644 --- a/frontend/src/Editor/Editor.jsx +++ b/frontend/src/Editor/Editor.jsx @@ -36,7 +36,17 @@ class Editor extends React.Component { super(props); const appId = this.props.match.params.id; + const currentUser = authenticationService.currentUserValue; + let userVars = { }; + + if(currentUser) { + userVars = { + email: currentUser.email, + firstName: currentUser.first_name, + lastName: currentUser.last_name + }; + } this.state = { currentUser: authenticationService.currentUserValue, @@ -57,11 +67,7 @@ class Editor extends React.Component { queries: {}, components: {}, globals: { - currentUser: { - firstName: currentUser.first_name, - lastName: currentUser.last_name, - email: currentUser.email - }, + currentUser: userVars, urlparams: {} } } diff --git a/frontend/src/Editor/ManageAppUsers.jsx b/frontend/src/Editor/ManageAppUsers.jsx index 82b645f636..8c3b062ead 100644 --- a/frontend/src/Editor/ManageAppUsers.jsx +++ b/frontend/src/Editor/ManageAppUsers.jsx @@ -35,7 +35,7 @@ class ManageAppUsers extends React.Component { } fetchAppUsers = () => { - appService.getAppUsers(this.state.app.id).then((data) => this.setState({ + appService.getAppUsers(this.props.app.id).then((data) => this.setState({ users: data.users, isLoading: false })); diff --git a/frontend/src/_components/PrivateRoute.jsx b/frontend/src/_components/PrivateRoute.jsx index 6bf481df58..9c2dd55bdd 100644 --- a/frontend/src/_components/PrivateRoute.jsx +++ b/frontend/src/_components/PrivateRoute.jsx @@ -7,11 +7,11 @@ export const PrivateRoute = ({ component: Component, ...rest }) => ( { - // const currentUser = authenticationService.currentUserValue; - // if (!currentUser) { - // // not logged in so redirect to login page with the return url - // return ; - // } + const currentUser = authenticationService.currentUserValue; + if (!currentUser && !props.location.pathname.startsWith('/applications/')) { + // not logged in so redirect to login page with the return url + return ; + } // authorised so return component return ;