Merge branch 'application-mgt-new' into 'application-mgt-new'

Redirect logged-out user within the loading screen in APPM UI

See merge request entgra/carbon-device-mgt!285
feature/appm-store/pbac
Dharmakeerthi Lasantha 5 years ago
commit 617ba8782f

@ -24,7 +24,7 @@ import {
Redirect, Switch,
} from 'react-router-dom';
import axios from "axios";
import {Layout, Spin, Result} from "antd";
import {Layout, Spin, Result, notification} from "antd";
import ConfigContext from "./context/ConfigContext";
const {Content} = Layout;
@ -68,9 +68,7 @@ class App extends React.Component {
window.location.origin + "/publisher/public/conf/config.json",
).then(res => {
const config = res.data;
this.getAndroidEnterpriseToken(config);
this.checkUserLoggedIn(config);
}).catch((error) => {
this.setState({
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() {
const {loading, error} = this.state;

@ -106,8 +106,6 @@ class AddNewReleaseFormComponent extends React.Component {
loading: true
});
const {price, isSharedWithAllTenants, icon, screenshots, releaseDescription, releaseType, binaryFile} = values;
const data = new FormData();
//add release data
@ -115,7 +113,7 @@ class AddNewReleaseFormComponent extends React.Component {
description: releaseDescription,
price: (price === undefined) ? 0 : parseInt(price),
isSharedWithAllTenants,
metaData: "string",
metaData: "[]",
releaseType: releaseType,
supportedOsVersions: `${this.lowerOsVersion}-${this.upperOsVersion}`
};
@ -132,7 +130,8 @@ class AddNewReleaseFormComponent extends React.Component {
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(
url,

@ -67,16 +67,44 @@ class App extends React.Component {
axios.get(
window.location.origin + "/store/public/conf/config.json",
).then(res => {
console.log(res);
const config = res.data;
this.checkUserLoggedIn(config);
}).catch((error) => {
this.setState({
loading: false,
config: res.data
error: true
})
});
}
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
})
}
});
}

@ -21,7 +21,8 @@ import {notification} from "antd";
export const handleApiError = (error, message) => {
console.log(error);
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 {
notification["error"]({
message: "There was a problem",

@ -162,6 +162,100 @@
<Scope>perm:android-work:customer</Scope>
<Scope>perm:android-work:admin</Scope>
<Scope>perm:application-command:modify</Scope>
<Scope>perm:sign-csr</Scope>
<Scope>perm:admin:devices:view</Scope>
<Scope>perm:admin:topics:view</Scope>
<Scope>perm:roles:add</Scope>
<Scope>perm:roles:add-users</Scope>
<Scope>perm:roles:update</Scope>
<Scope>perm:roles:permissions</Scope>
<Scope>perm:roles:details</Scope>
<Scope>perm:roles:view</Scope>
<Scope>perm:roles:create-combined-role</Scope>
<Scope>perm:roles:delete</Scope>
<Scope>perm:dashboard:vulnerabilities</Scope>
<Scope>perm:dashboard:non-compliant-count</Scope>
<Scope>perm:dashboard:non-compliant</Scope>
<Scope>perm:dashboard:by-groups</Scope>
<Scope>perm:dashboard:device-counts</Scope>
<Scope>perm:dashboard:feature-non-compliant</Scope>
<Scope>perm:dashboard:count-overview</Scope>
<Scope>perm:dashboard:filtered-count</Scope>
<Scope>perm:dashboard:details</Scope>
<Scope>perm:get-activity</Scope>
<Scope>perm:devices:delete</Scope>
<Scope>perm:devices:applications</Scope>
<Scope>perm:devices:effective-policy</Scope>
<Scope>perm:devices:compliance-data</Scope>
<Scope>perm:devices:features</Scope>
<Scope>perm:devices:operations</Scope>
<Scope>perm:devices:search</Scope>
<Scope>perm:devices:details</Scope>
<Scope>perm:devices:update</Scope>
<Scope>perm:devices:view</Scope>
<Scope>perm:view-configuration</Scope>
<Scope>perm:manage-configuration</Scope>
<Scope>perm:policies:remove</Scope>
<Scope>perm:policies:priorities</Scope>
<Scope>perm:policies:deactivate</Scope>
<Scope>perm:policies:get-policy-details</Scope>
<Scope>perm:policies:manage</Scope>
<Scope>perm:policies:activate</Scope>
<Scope>perm:policies:update</Scope>
<Scope>perm:policies:changes</Scope>
<Scope>perm:policies:get-details</Scope>
<Scope>perm:users:add</Scope>
<Scope>perm:users:details</Scope>
<Scope>perm:users:count</Scope>
<Scope>perm:users:delete</Scope>
<Scope>perm:users:roles</Scope>
<Scope>perm:users:user-details</Scope>
<Scope>perm:users:credentials</Scope>
<Scope>perm:users:search</Scope>
<Scope>perm:users:is-exist</Scope>
<Scope>perm:users:update</Scope>
<Scope>perm:users:send-invitation</Scope>
<Scope>perm:admin-users:view</Scope>
<Scope>perm:admin:devices:update-enrollment</Scope>
<Scope>perm:groups:devices</Scope>
<Scope>perm:groups:update</Scope>
<Scope>perm:groups:add</Scope>
<Scope>perm:groups:device</Scope>
<Scope>perm:groups:devices-count</Scope>
<Scope>perm:groups:remove</Scope>
<Scope>perm:groups:groups</Scope>
<Scope>perm:groups:groups-view</Scope>
<Scope>perm:groups:share</Scope>
<Scope>perm:groups:count</Scope>
<Scope>perm:groups:roles</Scope>
<Scope>perm:groups:devices-remove</Scope>
<Scope>perm:groups:devices-add</Scope>
<Scope>perm:groups:assign</Scope>
<Scope>perm:device-types:configs</Scope>
<Scope>perm:device-types:features</Scope>
<Scope>perm:device-types:types</Scope>
<Scope>perm:applications:install</Scope>
<Scope>perm:applications:uninstall</Scope>
<Scope>perm:admin-groups:count</Scope>
<Scope>perm:admin-groups:view</Scope>
<Scope>perm:notifications:mark-checked</Scope>
<Scope>perm:notifications:view</Scope>
<Scope>perm:admin:certificates:delete</Scope>
<Scope>perm:admin:certificates:details</Scope>
<Scope>perm:admin:certificates:view</Scope>
<Scope>perm:admin:certificates:add</Scope>
<Scope>perm:admin:certificates:verify</Scope>
<Scope>perm:admin</Scope>
<Scope>perm:devicetype:deployment</Scope>
<Scope>perm:device-types:events</Scope>
<Scope>perm:device-types:events:view</Scope>
<Scope>perm:admin:device-type</Scope>
<Scope>perm:admin:device-type:view</Scope>
<Scope>perm:admin:device-type:configs</Scope>
<Scope>perm:device:enroll</Scope>
<Scope>perm:geo-service:analytics-view</Scope>
<Scope>perm:geo-service:alerts-manage</Scope>
<Scope>appm:rea</Scope>
</Scopes>
<SSOConfiguration>
<Issuer>app-mgt</Issuer>

Loading…
Cancel
Save