|
|
@ -18,30 +18,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns the dynamic state to be populated by add-user page.
|
|
|
|
* Returns the dynamic state to be populated by add-user page.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param context Object that gets updated with the dynamic state of this page to be presented
|
|
|
|
* @param context Object that gets updated with the dynamic state of this page to be presented
|
|
|
|
* @returns {*} A context object that returns the dynamic state of this page to be presented
|
|
|
|
* @returns {*} A context object that returns the dynamic state of this page to be presented
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function onRequest(context) {
|
|
|
|
function onRequest(context) {
|
|
|
|
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
|
|
|
|
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
|
|
|
|
var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"];
|
|
|
|
var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"];
|
|
|
|
|
|
|
|
|
|
|
|
var uri = request.getRequestURI();
|
|
|
|
var uri = request.getRequestURI();
|
|
|
|
var uriMatcher = new URIMatcher(String(uri));
|
|
|
|
var uriMatcher = new URIMatcher(String(uri));
|
|
|
|
var isMatched = uriMatcher.match("/{context}/role/edit/{rolename}");
|
|
|
|
var isMatched = uriMatcher.match("/{context}/role/edit/{roleName}");
|
|
|
|
|
|
|
|
|
|
|
|
if (isMatched) {
|
|
|
|
if (isMatched) {
|
|
|
|
var matchedElements = uriMatcher.elements();
|
|
|
|
var matchedElements = uriMatcher.elements();
|
|
|
|
var roleName = matchedElements.rolename;
|
|
|
|
var roleName = matchedElements["roleName"];
|
|
|
|
var response = userModule.getRole(roleName);
|
|
|
|
var response = userModule.getRole(roleName);
|
|
|
|
if (response["status"] == "success") {
|
|
|
|
if (response["status"] == "success") {
|
|
|
|
context["role"] = response["content"];
|
|
|
|
context["role"] = response["content"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var userStores = userModule.getSecondaryUserStores();
|
|
|
|
var userStore;
|
|
|
|
context["userStores"] = userStores;
|
|
|
|
if (roleName.indexOf("/") > -1) {
|
|
|
|
|
|
|
|
userStore = roleName.substring(0, roleName.indexOf("/"));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
userStore = "PRIMARY";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
context["userStore"] = userStore;
|
|
|
|
|
|
|
|
context["roleNameJSRegEx"] = deviceMgtProps["roleValidationConfig"]["roleNameJSRegEx"];
|
|
|
|
|
|
|
|
context["roleNameHelpText"] = deviceMgtProps["roleValidationConfig"]["roleNameHelpMsg"];
|
|
|
|
|
|
|
|
context["roleNameRegExViolationErrorMsg"] = deviceMgtProps["roleValidationConfig"]["roleNameRegExViolationErrorMsg"];
|
|
|
|
|
|
|
|
return context;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//TODO: handle error scenario
|
|
|
|
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//TODO: error scenario
|
|
|
|
|
|
|
|
context["roleNameJSRegEx"] = deviceMgtProps.roleValidationConfig.rolenameJSRegEx;
|
|
|
|
|
|
|
|
context["roleNameHelpText"] = deviceMgtProps.roleValidationConfig.rolenameHelpMsg;
|
|
|
|
|
|
|
|
context["roleNameRegExViolationErrorMsg"] = deviceMgtProps.roleValidationConfig.rolenameRegExViolationErrorMsg;
|
|
|
|
|
|
|
|
return context;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|