From 41d2856e3921dd94d3c5d8d6ad8c1c1bc8450e62 Mon Sep 17 00:00:00 2001 From: kamidu Date: Thu, 8 Sep 2016 18:43:25 +0530 Subject: [PATCH] Enable permission check according to the new permissions --- .../pages/mdm.page.dashboard/dashboard.hbs | 4 --- .../app/pages/mdm.page.dashboard/dashboard.js | 12 ++++++--- .../mdm.unit.ui.navbar.nav-menu/nav-menu.hbs | 20 ++++---------- .../mdm.unit.ui.navbar.nav-menu/nav-menu.js | 27 ++++++++++--------- 4 files changed, 29 insertions(+), 34 deletions(-) diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.hbs index f5b9699730..0bf54e2c22 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.hbs +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.hbs @@ -19,7 +19,6 @@ {{unit "cdmf.unit.lib.qrcode"}} {{unit "mdm.unit.device.qr-modal"}} {{#zone "content"}} - {{#if permissions.VIEW_DASHBOARD}} {{#if permissions.LIST_DEVICES}}
@@ -151,9 +150,6 @@
{{/if}} - {{else}} - Permission denied - {{/if}} {{/zone}} {{#zone "bottomJs"}} {{js "js/dashboard.js"}} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js index e9b07a654b..a6c4955325 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js @@ -20,10 +20,16 @@ function onRequest(context) { var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var generalConfig = context.app.conf["generalConfig"]; var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; - var viewModel = {}; - viewModel.permissions = userModule.getUIPermissions(); - new Log().debug("## Permissions : " + stringify(userModule.getUIPermissions())); + var permissions = {}; + permissions.LIST_DEVICES = userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/view"); + permissions.LIST_POLICIES = userModule.isAuthorized("/permission/admin/device-mgt/policies/view"); + permissions.LIST_ROLES = userModule.isAuthorized("/permission/admin/device-mgt/roles/view"); + permissions.LIST_USERS = userModule.isAuthorized("/permission/admin/device-mgt/users/view"); + permissions.ADD_POLICY = userModule.isAuthorized("/permission/admin/device-mgt/policies/manage"); + permissions.ADD_ROLE = userModule.isAuthorized("/permission/admin/device-mgt/roles/manage"); + permissions.ADD_USER = userModule.isAuthorized("/permission/admin/device-mgt/users/manage"); + viewModel.permissions = permissions; //TODO: Move enrollment URL into app-conf.json viewModel.enrollmentURL = mdmProps.generalConfig.host + mdmProps.enrollmentDir; return viewModel; diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs index 18afc371ab..9d24059a25 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs @@ -22,30 +22,20 @@ {{/zone}} {{#zone "navMenu-items"}} - {{#if permissions.VIEW_DASHBOARD}}
  • Admin Dashboard
  • - {{/if}} - {{#if permissions.LIST_DEVICES_ADMIN}} + + {{#if permissions.LIST_DEVICES}}
  • Device Management
  • - {{else}} - {{#if permissions.LIST_OWN_DEVICES}} -
  • - - - Device Management - -
  • - {{/if}} {{/if}}
  • User Management @@ -64,12 +54,12 @@ {{/if}}
  • Configuration Management {{/zone}} {{#zone "sidePanes"}} -