From 81cd1f9eced89b564f0de06df4a64b7ce189caf7 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Sun, 26 Jul 2015 02:18:32 +0530 Subject: [PATCH 1/3] user api conflict resolved --- .../src/repository/jaggeryapps/iotserver/api/user-api.jag | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag b/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag index 0837370f..eacea91d 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag @@ -78,9 +78,9 @@ if (uriMatcher.match("/{context}/api/user/login/")) { } else { userRoles = String(addUserFormData.userRoles).split(","); } - userRoles=["deviceRole, deviceUser"]; - //TODO-Apply new users, - userRoles = []; + + userRoles="deviceRole,deviceUser".split(","); + try { result = userModule.registerUser(username, firstname, lastname, emailAddress, password, userRoles); From 11da6b4c2858bbb2cd2e3732d9c443abe18af0af Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Sun, 26 Jul 2015 04:04:20 +0530 Subject: [PATCH 2/3] fixing error in get users --- .../jaggeryapps/iotserver/modules/user.js | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/user.js b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/user.js index b8882e8f..e294a1e1 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/user.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/user.js @@ -250,16 +250,25 @@ userModule = function () { log.error("User object was not found in the session"); throw constants.ERRORS.USER_NOT_FOUND; } + 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); var userList = userManager.listUsers(); - - var i, userObject; - for (i = 0; i < userList.size(); i++) { - userObject = userList.get(i); - var userObj = { - "username" : userObject.getUserName(), - "email" : userObject.getEmail(), - "name" : userObject.getFirstName() + " " + userObject.getLastName() + var i, userObject, email, firstname, lastname; + for (i = 0; i < userList.length; i++) { + userObject = userManager.getUser(userList[i]); + email = userManager.getClaim(userList[i],"http://wso2.org/claims/emailaddress", null); + firstname = userManager.getClaim(userList[i],"http://wso2.org/claims/givenname", null); + lastname = userManager.getClaim(userList[i],"http://wso2.org/claims/lastname", null); + //log.info(userManager.getClaimsForSet(userList[i], new Array("http://wso2.org/claims/emailaddress", + // "http://wso2.org/claims/givenname", + // "http://wso2.org/claims/lastname"), null)); + userObj = { + "username" : userObject.username, + "email" : email, + "name" : firstname + " " + lastname }; if(userObj.username == "admin"){ userObj.name = "admin"; From 65fda67af193e8cd59bda5f65f93126a9b9e1ca1 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Sun, 26 Jul 2015 04:06:12 +0530 Subject: [PATCH 3/3] fixing error in policy listing module --- .../src/repository/jaggeryapps/iotserver/modules/policy.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/policy.js b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/policy.js index f1f45132..0e7d3f1e 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/policy.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/policy.js @@ -23,8 +23,6 @@ policyModule = function () { var constants = require("/modules/constants.js"); var utility = require("/modules/utility.js").utility; - var userManagementService = utility.getUserManagementService(); - var publicMethods = {}; var privateMethods = {};