Fixes for public applications

This commit is contained in:
navaneeth 2021-05-07 15:56:51 +05:30
parent 2787d9efd5
commit c58f01eb52
3 changed files with 17 additions and 11 deletions

View file

@ -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: {}
}
}

View file

@ -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
}));

View file

@ -7,11 +7,11 @@ export const PrivateRoute = ({ component: Component, ...rest }) => (
<Route
{...rest}
render={(props) => {
// const currentUser = authenticationService.currentUserValue;
// if (!currentUser) {
// // not logged in so redirect to login page with the return url
// return <Redirect to={{ pathname: '/login', state: { from: props.location } }} />;
// }
const currentUser = authenticationService.currentUserValue;
if (!currentUser && !props.location.pathname.startsWith('/applications/')) {
// not logged in so redirect to login page with the return url
return <Redirect to={{ pathname: '/login', state: { from: props.location } }} />;
}
// authorised so return component
return <Component {...props} />;