From a9d00964d2811db35e91d30db1ff9d254bd2dba1 Mon Sep 17 00:00:00 2001
From: dilanua
+ Permission Denied
+
+
+ You are not authorized to view any enrolled device in the system.
+ {{/if}}
{{/zone}}
\ No newline at end of file
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.device.view/view.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.js
index 21ce993020..1f7e9c0881 100644
--- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.js
+++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.js
@@ -17,17 +17,24 @@
*/
function onRequest(context){
- var utility = require("/app/modules/utility.js").utility;
- context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) {
- if (arguments.length < 3)
- throw new Error("Handlebars Helper equal needs 2 parameters");
- if( lvalue!=rvalue ) {
- return options.inverse(this);
- } else {
- return options.fn(this);
- }
- });
+ var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
+ var viewModel = {};
- var deviceType = context.uriParams.deviceType;
- return {"deviceViewUnitName": utility.getTenantedDeviceUnitName(deviceType, "device-view")};
+ // permission checks
+ // [1] checking viewing devices permission
+ viewModel["isAuthorized"] = userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/view");
+
+ if (viewModel["isAuthorized"]) {
+ context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) {
+ if (arguments.length < 3)
+ throw new Error("Handlebars Helper equal needs 2 parameters");
+ if( lvalue!=rvalue ) {
+ return options.inverse(this);
+ } else {
+ return options.fn(this);
+ }
+ });
+ }
+
+ return viewModel;
}
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.devices/devices.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.hbs
index 0c56529574..b56d066f1c 100644
--- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.hbs
+++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.hbs
@@ -156,6 +156,12 @@