change 401 redirection in APPM store Ui

feature/appm-store/pbac
Jayasanka 6 years ago
parent 3c6ba111a9
commit 92fd8a62be

@ -4,6 +4,7 @@
"value": "lightBaseTheme" "value": "lightBaseTheme"
}, },
"serverConfig": { "serverConfig": {
"protocol": "https",
"hostname": "localhost", "hostname": "localhost",
"httpsPort": "9443", "httpsPort": "9443",
"invokerUri": "/api/application-mgt-handler/v1.0/invoke", "invokerUri": "/api/application-mgt-handler/v1.0/invoke",

@ -36,7 +36,7 @@ class ReleaseView extends React.Component {
loading: true, loading: true,
}); });
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 => { ).then(res => {
if (res.status === 201) { if (res.status === 201) {
this.setState({ this.setState({
@ -61,7 +61,7 @@ class ReleaseView extends React.Component {
}).catch((error) => { }).catch((error) => {
if (error.response.status === 401) { 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+'/store/login';
} else { } else {
this.setState({ this.setState({
loading: false, loading: false,

@ -38,7 +38,7 @@ class UserInstall extends React.Component {
const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&'); const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&');
console.log(request); 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 => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
if (fetchId !== this.lastFetchId) { if (fetchId !== this.lastFetchId) {
@ -59,7 +59,7 @@ class UserInstall extends React.Component {
}).catch((error) => { }).catch((error) => {
if (error.response.hasOwnProperty(status) && error.response.status === 401) { if (error.response.hasOwnProperty(status) && error.response.status === 401) {
message.error('You are not logged in'); 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+'/store/login';
} else { } else {
message.error('Something went wrong... :('); message.error('Something went wrong... :(');
} }

@ -54,7 +54,7 @@ class AddReview extends React.Component {
const request = "method=post&content-type=application/json&payload="+JSON.stringify(payload)+"&api-endpoint=/application-mgt-store/v1.0/reviews/"+uuid; const request = "method=post&content-type=application/json&payload="+JSON.stringify(payload)+"&api-endpoint=/application-mgt-store/v1.0/reviews/"+uuid;
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 => { ).then(res => {
if (res.status === 201) { if (res.status === 201) {
this.setState({ this.setState({
@ -84,7 +84,7 @@ class AddReview extends React.Component {
}).catch((error) =>{ }).catch((error) =>{
if (error.response.status === 401) { 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+'/store/login';
} else{ } else{
this.setState({ this.setState({
loading: false, loading: false,

@ -28,7 +28,7 @@ class Reviews extends React.Component {
fetchData = (offset, limit, callback) => { fetchData = (offset, limit, callback) => {
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/reviews/" + this.props.uuid + "?offset=" + offset + "%26limit=" + limit; const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/reviews/" + this.props.uuid + "?offset=" + offset + "%26limit=" + limit;
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 => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let reviews = res.data.data.data; let reviews = res.data.data.data;
@ -37,7 +37,7 @@ class Reviews extends React.Component {
}).catch(function (error) { }).catch(function (error) {
if (error.response.status === 401) { 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 + '/store/login';
} else { } else {
message.warning('Something went wrong'); message.warning('Something went wrong');

@ -6,7 +6,7 @@ export const getApps = () => dispatch => {
const request = "method=post&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/applications"; const request = "method=post&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/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 => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let apps = []; let apps = [];
@ -19,7 +19,7 @@ export const getApps = () => dispatch => {
}).catch(function (error) { }).catch(function (error) {
if (error.response.status === 401) { 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+'/store/login';
} }
}); });
@ -29,7 +29,7 @@ export const getRelease = (uuid) => dispatch => {
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/applications/" + uuid; const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/applications/" + 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 => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let release = res.data.data.applicationReleases[0]; let release = res.data.data.applicationReleases[0];
@ -43,7 +43,7 @@ export const getRelease = (uuid) => dispatch => {
} }
}).catch(function (error) { }).catch(function (error) {
if (error.response.status === 401) { 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+'/store/login';
}else if(error.response.status===404){ }else if(error.response.status===404){
dispatch({ dispatch({
type: ActionTypes.GET_RELEASE, type: ActionTypes.GET_RELEASE,
@ -94,7 +94,7 @@ export const setLoading = (stateToLoad) => dispatch => {
export const getLifecycle = () => dispatch => { export const getLifecycle = () => dispatch => {
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/applications/lifecycle-config"; const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/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 => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let lifecycle = res.data.data; let lifecycle = res.data.data;
@ -103,7 +103,7 @@ export const getLifecycle = () => dispatch => {
}).catch(function (error) { }).catch(function (error) {
if (error.response.status === 401) { 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+'/store/login';
} }
}); });
}; };
@ -118,7 +118,7 @@ export const updateLifecycleState = (uuid, nextState, reason) => dispatch => {
const request = "method=post&content-type=application/json&payload=" + JSON.stringify(payload) + "&api-endpoint=/application-mgt-store/v1.0/applications/life-cycle/" + uuid; const request = "method=post&content-type=application/json&payload=" + JSON.stringify(payload) + "&api-endpoint=/application-mgt-store/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 => { ).then(res => {
if (res.status === 201) { if (res.status === 201) {
let release = res.data.data; let release = res.data.data;
@ -132,7 +132,7 @@ export const updateLifecycleState = (uuid, nextState, reason) => dispatch => {
}).catch(function (error) { }).catch(function (error) {
if (error.response.status === 401) { 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+'/store/login';
} else if (error.response.status === 500) { } else if (error.response.status === 500) {
alert("error"); alert("error");
dispatch({ dispatch({
@ -147,7 +147,7 @@ export const updateLifecycleState = (uuid, nextState, reason) => dispatch => {
export const getDetailedRating = (uuid) => dispatch => { export const getDetailedRating = (uuid) => dispatch => {
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/reviews/"+uuid+"/rating"; 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 => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let detailedRating = res.data.data; let detailedRating = res.data.data;
@ -156,7 +156,7 @@ export const getDetailedRating = (uuid) => dispatch => {
}).catch(function (error) { }).catch(function (error) {
if (error.response.status === 401) { 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+'/store/login';
} else{ } else{
dispatch({ dispatch({
type: ActionTypes.GET_DETAILED_RATING, payload: null type: ActionTypes.GET_DETAILED_RATING, payload: null

@ -58,7 +58,7 @@ class NormalLoginForm extends React.Component {
loading: true loading: true
}); });
let data = "username=" + values.username + "&password=" + values.password + "&platform=store"; let data = "username=" + values.username + "&password=" + values.password + "&platform=store";
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 => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
window.location = res.data.url; window.location = res.data.url;

Loading…
Cancel
Save