From 3333ed03812be0f4f8c6cff0c9de2ab41effa797 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Mon, 19 Jun 2017 19:18:34 +0530 Subject: [PATCH 1/2] Fixing permission issue which resolves wso2/product-iots#430 --- .../devicemgt/app/modules/business-controllers/user.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js index f8c420d58c..ff37153c43 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js @@ -110,6 +110,7 @@ var userModule = function () { * @returns {number} HTTP Status code 201 if succeeded, 409 if user already exists */ publicMethods.registerUser = function (username, firstname, lastname, emailAddress, password, userRoles) { + log.info("Register user:::::::::"); var carbon = require('carbon'); var tenantId = carbon.server.tenantId(); var url = carbon.server.address('https') + "/admin/services"; @@ -632,11 +633,17 @@ var userModule = function () { var url = carbon.server.address('https') + "/admin/services"; var server = new carbon.server.Server(url); var userManager = new carbon.user.UserManager(server, tenantId); + try { if (!userManager.roleExists(roleName)) { userManager.addRole(roleName, users, permissions); } else { - log.info("Role exist with name: " + roleName); + var array = Object.keys(permissions); + var i, permission; + for (i = 0; i < array.length; i++) { + permission = array[i]; + userManager.authorizeRole(roleName, permission, "ui.execute"); + } } } catch (e) { throw e; From 19495321d2374afaf1081ca26eee8b8d70fba668 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Mon, 19 Jun 2017 19:23:01 +0530 Subject: [PATCH 2/2] removing unnecessary lines --- .../devicemgt/app/modules/business-controllers/user.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js index ff37153c43..24e7cc696d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js @@ -110,13 +110,11 @@ var userModule = function () { * @returns {number} HTTP Status code 201 if succeeded, 409 if user already exists */ publicMethods.registerUser = function (username, firstname, lastname, emailAddress, password, userRoles) { - log.info("Register user:::::::::"); var carbon = require('carbon'); var tenantId = carbon.server.tenantId(); var url = carbon.server.address('https') + "/admin/services"; var server = new carbon.server.Server(url); var userManager = new carbon.user.UserManager(server, tenantId); - try { if (userManager.userExists(username)) { if (log.isDebugEnabled()) {