|
|
@ -110,6 +110,7 @@ var userModule = function () {
|
|
|
|
* @returns {number} HTTP Status code 201 if succeeded, 409 if user already exists
|
|
|
|
* @returns {number} HTTP Status code 201 if succeeded, 409 if user already exists
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
publicMethods.registerUser = function (username, firstname, lastname, emailAddress, password, userRoles) {
|
|
|
|
publicMethods.registerUser = function (username, firstname, lastname, emailAddress, password, userRoles) {
|
|
|
|
|
|
|
|
log.info("Register user:::::::::");
|
|
|
|
var carbon = require('carbon');
|
|
|
|
var carbon = require('carbon');
|
|
|
|
var tenantId = carbon.server.tenantId();
|
|
|
|
var tenantId = carbon.server.tenantId();
|
|
|
|
var url = carbon.server.address('https') + "/admin/services";
|
|
|
|
var url = carbon.server.address('https') + "/admin/services";
|
|
|
@ -632,11 +633,17 @@ var userModule = function () {
|
|
|
|
var url = carbon.server.address('https') + "/admin/services";
|
|
|
|
var url = carbon.server.address('https') + "/admin/services";
|
|
|
|
var server = new carbon.server.Server(url);
|
|
|
|
var server = new carbon.server.Server(url);
|
|
|
|
var userManager = new carbon.user.UserManager(server, tenantId);
|
|
|
|
var userManager = new carbon.user.UserManager(server, tenantId);
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (!userManager.roleExists(roleName)) {
|
|
|
|
if (!userManager.roleExists(roleName)) {
|
|
|
|
userManager.addRole(roleName, users, permissions);
|
|
|
|
userManager.addRole(roleName, users, permissions);
|
|
|
|
} else {
|
|
|
|
} 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) {
|
|
|
|
} catch (e) {
|
|
|
|
throw e;
|
|
|
|
throw e;
|
|
|
|