From 112eb1f77f50c86ddf7b5431504cdde7f609dc1f Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Fri, 11 Oct 2019 12:31:49 +0530 Subject: [PATCH] Call user API to get logged-in user's data when loading APPM publisher UI --- .../react-app/src/App.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.js index 801f875404..cc0ab3486b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.js @@ -98,19 +98,24 @@ class App extends React.Component { }; checkUserLoggedIn = (config) => { - axios.get( - window.location.origin + config.serverConfig.invoker.uri + - config.serverConfig.invoker.publisher + "/applications/categories" + axios.post( + window.location.origin + "/publisher-ui-request-handler/user", + "platform=publisher" ).then(res => { - this.getAndroidEnterpriseToken(config); + const lastURLSegment = pageURL.substr(pageURL.lastIndexOf('/') + 1); + if (lastURLSegment !== "login") { + window.location.href = window.location.origin + `/publisher/`; + } else { + this.getAndroidEnterpriseToken(config); + } }).catch((error) => { if (error.hasOwnProperty("response") && error.response.status === 401) { const redirectUrl = encodeURI(window.location.href); const pageURL = window.location.pathname; const lastURLSegment = pageURL.substr(pageURL.lastIndexOf('/') + 1); - if(lastURLSegment!=="login"){ + if (lastURLSegment !== "login") { window.location.href = window.location.origin + `/publisher/login?redirect=${redirectUrl}`; - }else{ + } else { this.getAndroidEnterpriseToken(config); } } else {