mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Redirect logged-out user within the loading screen in APPM UI
This commit is contained in:
parent
f1f7a3d9e3
commit
8b4c2f0e79
@ -24,7 +24,7 @@ import {
|
|||||||
Redirect, Switch,
|
Redirect, Switch,
|
||||||
} from 'react-router-dom';
|
} from 'react-router-dom';
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {Layout, Spin, Result} from "antd";
|
import {Layout, Spin, Result, notification} from "antd";
|
||||||
import ConfigContext from "./context/ConfigContext";
|
import ConfigContext from "./context/ConfigContext";
|
||||||
|
|
||||||
const {Content} = Layout;
|
const {Content} = Layout;
|
||||||
@ -68,9 +68,7 @@ class App extends React.Component {
|
|||||||
window.location.origin + "/publisher/public/conf/config.json",
|
window.location.origin + "/publisher/public/conf/config.json",
|
||||||
).then(res => {
|
).then(res => {
|
||||||
const config = res.data;
|
const config = res.data;
|
||||||
|
this.checkUserLoggedIn(config);
|
||||||
this.getAndroidEnterpriseToken(config);
|
|
||||||
|
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: false,
|
loading: false,
|
||||||
@ -99,6 +97,31 @@ class App extends React.Component {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
checkUserLoggedIn = (config) => {
|
||||||
|
axios.get(
|
||||||
|
window.location.origin + config.serverConfig.invoker.uri +
|
||||||
|
config.serverConfig.invoker.publisher + "/applications/categories"
|
||||||
|
).then(res => {
|
||||||
|
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"){
|
||||||
|
window.location.href = window.location.origin + `/publisher/login?redirect=${redirectUrl}`;
|
||||||
|
}else{
|
||||||
|
this.getAndroidEnterpriseToken(config);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
error: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {loading, error} = this.state;
|
const {loading, error} = this.state;
|
||||||
|
|
||||||
|
|||||||
@ -106,8 +106,6 @@ class AddNewReleaseFormComponent extends React.Component {
|
|||||||
loading: true
|
loading: true
|
||||||
});
|
});
|
||||||
const {price, isSharedWithAllTenants, icon, screenshots, releaseDescription, releaseType, binaryFile} = values;
|
const {price, isSharedWithAllTenants, icon, screenshots, releaseDescription, releaseType, binaryFile} = values;
|
||||||
|
|
||||||
|
|
||||||
const data = new FormData();
|
const data = new FormData();
|
||||||
|
|
||||||
//add release data
|
//add release data
|
||||||
@ -115,7 +113,7 @@ class AddNewReleaseFormComponent extends React.Component {
|
|||||||
description: releaseDescription,
|
description: releaseDescription,
|
||||||
price: (price === undefined) ? 0 : parseInt(price),
|
price: (price === undefined) ? 0 : parseInt(price),
|
||||||
isSharedWithAllTenants,
|
isSharedWithAllTenants,
|
||||||
metaData: "string",
|
metaData: "[]",
|
||||||
releaseType: releaseType,
|
releaseType: releaseType,
|
||||||
supportedOsVersions: `${this.lowerOsVersion}-${this.upperOsVersion}`
|
supportedOsVersions: `${this.lowerOsVersion}-${this.upperOsVersion}`
|
||||||
};
|
};
|
||||||
@ -132,7 +130,8 @@ class AddNewReleaseFormComponent extends React.Component {
|
|||||||
|
|
||||||
data.append("applicationRelease", blob);
|
data.append("applicationRelease", blob);
|
||||||
|
|
||||||
const url = window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/" + deviceType + "/ent-app/" + appId;
|
const url = window.location.origin + config.serverConfig.invoker.uri +
|
||||||
|
config.serverConfig.invoker.publisher + "/applications/" + deviceType + "/ent-app/" + appId;
|
||||||
|
|
||||||
axios.post(
|
axios.post(
|
||||||
url,
|
url,
|
||||||
|
|||||||
@ -67,11 +67,8 @@ class App extends React.Component {
|
|||||||
axios.get(
|
axios.get(
|
||||||
window.location.origin + "/store/public/conf/config.json",
|
window.location.origin + "/store/public/conf/config.json",
|
||||||
).then(res => {
|
).then(res => {
|
||||||
console.log(res);
|
const config = res.data;
|
||||||
this.setState({
|
this.checkUserLoggedIn(config);
|
||||||
loading: false,
|
|
||||||
config: res.data
|
|
||||||
})
|
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: false,
|
loading: false,
|
||||||
@ -80,6 +77,37 @@ class App extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkUserLoggedIn = (config) => {
|
||||||
|
axios.get(
|
||||||
|
window.location.origin + config.serverConfig.invoker.uri +
|
||||||
|
config.serverConfig.invoker.publisher + "/applications/categories"
|
||||||
|
).then(res => {
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
config: 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"){
|
||||||
|
window.location.href = window.location.origin + `/store/login?redirect=${redirectUrl}`;
|
||||||
|
}else{
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
config: config
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
error: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {loading, error} = this.state;
|
const {loading, error} = this.state;
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,8 @@ import {notification} from "antd";
|
|||||||
export const handleApiError = (error, message) => {
|
export const handleApiError = (error, message) => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
if (error.hasOwnProperty("response") && error.response.status === 401) {
|
if (error.hasOwnProperty("response") && error.response.status === 401) {
|
||||||
window.location.href = window.location.origin + '/store/login';
|
const redirectUrl = encodeURI(window.location.href);
|
||||||
|
window.location.href = window.location.origin + `/store/login?redirect=${redirectUrl}`;
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: "There was a problem",
|
message: "There was a problem",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user