|
|
@ -141,6 +141,35 @@ var userModule = function () {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Get users count from backend services.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
publicMethods.getUsersCount = function () {
|
|
|
|
|
|
|
|
var carbonUser = session.get(constants["USER_SESSION_KEY"]);
|
|
|
|
|
|
|
|
var utility = require("/app/modules/utility.js")["utility"];
|
|
|
|
|
|
|
|
if (!carbonUser) {
|
|
|
|
|
|
|
|
log.error("User object was not found in the session");
|
|
|
|
|
|
|
|
throw constants["ERRORS"]["USER_NOT_FOUND"];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
utility.startTenantFlow(carbonUser);
|
|
|
|
|
|
|
|
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users?offset=0&limit=1";
|
|
|
|
|
|
|
|
return serviceInvokers.XMLHttp.get(
|
|
|
|
|
|
|
|
url, function (responsePayload) {
|
|
|
|
|
|
|
|
return parse(responsePayload["responseText"])["count"];
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
function (responsePayload) {
|
|
|
|
|
|
|
|
log.error(responsePayload["responseText"]);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
utility.endTenantFlow();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Return a User object from the backend by calling the JAX-RS
|
|
|
|
* Return a User object from the backend by calling the JAX-RS
|
|
|
|
* @param username
|
|
|
|
* @param username
|
|
|
@ -236,6 +265,36 @@ var userModule = function () {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Get User Roles count from user store (Internal roles not included).
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
publicMethods.getRolesCount = function () {
|
|
|
|
|
|
|
|
var carbonUser = session.get(constants["USER_SESSION_KEY"]);
|
|
|
|
|
|
|
|
var utility = require("/app/modules/utility.js")["utility"];
|
|
|
|
|
|
|
|
if (!carbonUser) {
|
|
|
|
|
|
|
|
log.error("User object was not found in the session");
|
|
|
|
|
|
|
|
throw constants["ERRORS"]["USER_NOT_FOUND"];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
utility.startTenantFlow(carbonUser);
|
|
|
|
|
|
|
|
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
|
|
|
|
|
|
|
|
"/roles?offset=0&limit=1";
|
|
|
|
|
|
|
|
return serviceInvokers.XMLHttp.get(
|
|
|
|
|
|
|
|
url, function (responsePayload) {
|
|
|
|
|
|
|
|
return parse(responsePayload["responseText"])["count"];
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
function (responsePayload) {
|
|
|
|
|
|
|
|
log.error(responsePayload["responseText"]);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
utility.endTenantFlow();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
@Updated
|
|
|
|
@Updated
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|