From a9de6af5f724039d86dc0e61b7701b7c62927c45 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Wed, 12 Jun 2019 13:35:53 +0530 Subject: [PATCH] change 401 redirection in APPM publisher Ui --- .../react-app/public/conf/config.json | 1 + .../apps/detailed-rating/DetailedRating.js | 4 ++-- .../src/components/apps/list-apps/AppsTable.js | 4 ++-- .../manage/categories/ManageCategories.js | 16 ++++++++-------- .../components/manage/categories/ManageTags.js | 16 ++++++++-------- .../react-app/src/js/actions/index.js | 16 ++++++++-------- .../react-app/src/pages/Login.js | 2 +- 7 files changed, 30 insertions(+), 29 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json index 47b11b05c19..8ac3b835777 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json @@ -4,6 +4,7 @@ "value": "lightBaseTheme" }, "serverConfig": { + "protocol": "https", "hostname": "localhost", "httpsPort": "9443", "invokerUri": "/api/application-mgt-handler/v1.0/invoke", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/detailed-rating/DetailedRating.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/detailed-rating/DetailedRating.js index 5d764c99ea1..da83fc878f3 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/detailed-rating/DetailedRating.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/detailed-rating/DetailedRating.js @@ -30,7 +30,7 @@ class DetailedRating extends React.Component{ getData = (uuid)=>{ const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/reviews/"+uuid+"/rating"; - return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { let detailedRating = res.data.data; @@ -41,7 +41,7 @@ class DetailedRating extends React.Component{ }).catch(function (error) { if (error.response.status === 401) { - window.location.href = 'https://localhost:9443/store/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } }); }; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js index 9095b68b158..89949eb56e9 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js @@ -120,7 +120,7 @@ class ConnectedAppsTable extends React.Component { const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&'); console.log(request); - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { let apps = []; @@ -143,7 +143,7 @@ class ConnectedAppsTable extends React.Component { }).catch((error) => { if (error.response.status === 401) { message.error('You are not logged in'); - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.error('Something went wrong... :('); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageCategories.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageCategories.js index f4fa06b6c5e..ace79ba0b4c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageCategories.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageCategories.js @@ -21,7 +21,7 @@ class ManageCategories extends React.Component { componentDidMount() { const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/categories"; - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { let categories = JSON.parse(res.data.data); @@ -33,7 +33,7 @@ class ManageCategories extends React.Component { }).catch((error) => { if (error.response.status === 401) { - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.warning('Something went wrong'); @@ -56,7 +56,7 @@ class ManageCategories extends React.Component { loading: true }); const request = "method=delete&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories/" + id; - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { notification["success"]({ @@ -83,7 +83,7 @@ class ManageCategories extends React.Component { }).catch((error) => { if (error.response.hasOwnProperty("status") && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.warning('Something went wrong'); } @@ -198,7 +198,7 @@ class ManageCategories extends React.Component { const dataArray = JSON.stringify(tempElements.map(category => category.categoryName)); const request = "method=post&content-type=application/json&payload=" + dataArray + "&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories"; - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { notification["success"]({ @@ -220,7 +220,7 @@ class ManageCategories extends React.Component { }).catch((error) => { if (error.response.hasOwnProperty("status") && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.warning('Something went wrong'); } @@ -259,7 +259,7 @@ class ManageCategories extends React.Component { isEditModalVisible: false, }); const request = "method=put&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories/rename?from="+currentlyEditingId+"%26to="+editingValue; - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { notification["success"]({ @@ -280,7 +280,7 @@ class ManageCategories extends React.Component { }).catch((error) => { if (error.response.hasOwnProperty("status") && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.warning('Something went wrong'); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageTags.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageTags.js index 726b9225d2f..047669ca593 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageTags.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageTags.js @@ -21,7 +21,7 @@ class ManageTags extends React.Component { componentDidMount() { const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/tags"; - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { let categories = JSON.parse(res.data.data); @@ -33,7 +33,7 @@ class ManageTags extends React.Component { }).catch((error) => { if (error.response.status === 401) { - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.warning('Something went wrong'); @@ -56,7 +56,7 @@ class ManageTags extends React.Component { loading: true }); const request = "method=delete&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories/" + id; - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { notification["success"]({ @@ -81,7 +81,7 @@ class ManageTags extends React.Component { }).catch((error) => { if (error.response.hasOwnProperty("status") && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.warning('Something went wrong'); } @@ -196,7 +196,7 @@ class ManageTags extends React.Component { const dataArray = JSON.stringify(tempElements.map(category => category.categoryName)); const request = "method=post&content-type=application/json&payload=" + dataArray + "&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories"; - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { notification["success"]({ @@ -218,7 +218,7 @@ class ManageTags extends React.Component { }).catch((error) => { if (error.response.hasOwnProperty("status") && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.warning('Something went wrong'); } @@ -257,7 +257,7 @@ class ManageTags extends React.Component { isEditModalVisible: false, }); const request = "method=put&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories?from="+currentlyEditingId+"%26to="+editingValue; - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { notification["success"]({ @@ -278,7 +278,7 @@ class ManageTags extends React.Component { }).catch((error) => { if (error.response.hasOwnProperty("status") && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.warning('Something went wrong'); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js index 42bfd2c3a93..b26e84c2093 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js @@ -6,7 +6,7 @@ export const getApps = () => dispatch => { const request = "method=post&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications"; - return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { let apps = []; @@ -19,7 +19,7 @@ export const getApps = () => dispatch => { }).catch(function (error) { if (error.response.status === 401) { - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } }); @@ -29,7 +29,7 @@ export const getRelease = (uuid) => dispatch => { const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/release/" + uuid; - return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { let release = res.data.data; @@ -38,7 +38,7 @@ export const getRelease = (uuid) => dispatch => { }).catch(function (error) { if (error.response.status === 401) { - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } }); @@ -73,7 +73,7 @@ export const closeLifecycleModal = () => dispatch => { export const getLifecycle = () => dispatch => { const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/lifecycle-config"; - return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { let lifecycle = res.data.data; @@ -82,7 +82,7 @@ export const getLifecycle = () => dispatch => { }).catch(function (error) { if (error.response.status === 401) { - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } }); }; @@ -97,7 +97,7 @@ export const updateLifecycleState = (uuid, nextState, reason) => dispatch => { const request = "method=post&content-type=application/json&payload=" + JSON.stringify(payload) + "&api-endpoint=/application-mgt-publisher/v1.0/applications/life-cycle/" + uuid; - return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 201) { let release = res.data.data; @@ -111,7 +111,7 @@ export const updateLifecycleState = (uuid, nextState, reason) => dispatch => { }).catch(function (error) { if (error.response.status === 401) { - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else if (error.response.status === 500) { alert("error"); dispatch({ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/Login.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/Login.js index 8953e323527..030a43dfe43 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/Login.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/Login.js @@ -59,7 +59,7 @@ class NormalLoginForm extends React.Component { }); console.log('Received values of form: ', values); let data = "username=" + values.username + "&password=" + values.password + "&platform=publisher"; - axios.post('https://'+config.serverConfig.hostname+':'+config.serverConfig.httpsPort+config.serverConfig.loginUri, data + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname+':'+config.serverConfig.httpsPort+config.serverConfig.loginUri, data ).then(res => { if (res.status === 200) { window.location = res.data.url;