Fixes related to having special characters in role name

revert-70aa11f8
Megala 8 years ago
parent a04f91cddb
commit e55b3a6d5f

@ -175,7 +175,6 @@
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.user.core</artifactId>
<version>4.4.3</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.registry</groupId>

@ -187,7 +187,7 @@ var userModule = function () {
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users/" +
encodeURIComponent(username);
if (domain) {
url += '?domain=' + domain;
url += '?domain=' + encodeURIComponent(domain);
}
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
response["content"] = parse(response.content);
@ -217,7 +217,7 @@ var userModule = function () {
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users/" +
encodeURIComponent(username) + "/roles";
if (domain) {
url += '?domain=' + domain;
url += '?domain=' + encodeURIComponent(domain);
}
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
if (response.status == "success") {
@ -328,7 +328,7 @@ var userModule = function () {
try {
utility.startTenantFlow(carbonUser);
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
"/roles?user-store=" + userStore + "&limit=100";
"/roles?user-store=" + encodeURIComponent(userStore) + "&limit=100";
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
if (response.status == "success") {
response.content = parse(response.content).roles;
@ -388,7 +388,7 @@ var userModule = function () {
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
"/roles/" + encodeURIComponent(roleName);
if (userStore) {
url += "?user-store=" + userStore;
url += "?user-store=" + encodeURIComponent(userStore);
}
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
if (response.status == "success") {

@ -130,7 +130,7 @@ $(document).ready(function () {
var postData = {};
postData.requestMethod = "GET";
postData.requestURL = "/api/device-mgt/v1.0/users/search/usernames?filter=" + params.term +
"&domain=" + domain;
"&domain=" + encodeURIComponent(domain);
postData.requestPayload = null;
return JSON.stringify(postData);
},
@ -204,7 +204,7 @@ $(document).ready(function () {
$("input#roleName").val("");
$("#domain").val("PRIMARY");
$("#users").val("");
window.location.href = appContext + "/role/edit-permission/" + addRoleFormData.roleName;
window.location.href = appContext + "/role/edit-permission/?rolename=" + encodeURIComponent(addRoleFormData.roleName);
}
},
function (jqXHR) {

@ -1,5 +1,5 @@
{
"version": "1.0.0",
"uri": "/role/edit-permission/{+any}",
"uri": "/role/edit-permission/",
"layout": "cdmf.layout.default"
}

@ -206,9 +206,9 @@ $("#role-grid").on("click", ".remove-role-link", function () {
userStore = role.substr(0, role.indexOf('/'));
role = role.substr(role.indexOf('/') + 1);
}
var removeRoleAPI = apiBasePath + "/roles/" + role;
var removeRoleAPI = apiBasePath + "/roles/" + encodeURIComponent(role);
if (userStore) {
removeRoleAPI += "?user-store=" + userStore;
removeRoleAPI += "?user-store=" + encodeURIComponent(userStore);
}
$(modalPopupContent).html($('#remove-role-modal-content').html());
showPopup();

@ -180,8 +180,7 @@ $("#userStore").change(
str += $(this).text() + "";
});
if ($("#roles").length > 0) {
var getRolesAPI = deviceMgtAPIsBasePath + "/roles?user-store=" + str + "&limit=100";
var getRolesAPI = deviceMgtAPIsBasePath + "/roles?user-store=" + encodeURIComponent(str) + "&limit=100";
invokerUtil.get(
getRolesAPI,
function (data) {
@ -189,7 +188,7 @@ $("#userStore").change(
if (data.errorMessage) {
$(errorMsg).text("Selected user store prompted an error : " + data.errorMessage);
$(errorMsgWrapper).removeClass("hidden");
} else if (data.count > 0) {
} else {
$("#roles").empty();
for (var i = 0; i < data.roles.length; i++) {
var newOption = $('<option value="' + data.roles[i] + '">' + data.roles[i] + '</option>');

@ -236,7 +236,8 @@ $(document).ready(function () {
}
addUserFormData.roles = roles;
username = username.substr(username.indexOf('/') + 1);
var addUserAPI = deviceMgtBasePath + "/users/" + username + "?domain=" + domain;
var addUserAPI = deviceMgtBasePath + "/users/" + encodeURIComponent(username) + "?domain=" +
encodeURIComponent(domain);
invokerUtil.put(
addUserAPI,

@ -158,7 +158,7 @@ function resetPassword(username) {
}
var resetPasswordServiceURL = apiBasePath + "/admin/users/" + username + "/credentials";
if (domain) {
resetPasswordServiceURL += '?domain=' + domain;
resetPasswordServiceURL += '?domain=' + encodeURIComponent(domain);
}
invokerUtil.post(
resetPasswordServiceURL,
@ -198,11 +198,10 @@ function removeUser(username) {
domain = username.substr(0, username.indexOf('/'));
username = username.substr(username.indexOf('/') + 1);
}
var removeUserAPI = apiBasePath + "/users/" + username;
var removeUserAPI = apiBasePath + "/users/" + encodeURIComponent(username);
if (domain) {
removeUserAPI += '?domain=' + domain;
removeUserAPI += '?domain=' + encodeURIComponent(domain);
}
modalDialog.header("Remove User");
modalDialog.content("Do you really want to remove this user ?");
modalDialog.footer('<div class="buttons"> <a href="#" id="remove-user-yes-link" class="btn-operations">Remove</a> ' +

@ -24,22 +24,6 @@
*/
function onRequest(context) {
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var uri = request.getRequestURI();
var uriMatcher = new URIMatcher(String(uri));
var isMatched = uriMatcher.match("/{context}/role/edit-permission/{rolename}");
var matchedElements;
var roleName;
var userStore;
if (isMatched) {
matchedElements = uriMatcher.elements();
roleName = matchedElements.rolename;
context["roleName"] = roleName;
} else if (uriMatcher.match("/{context}/role/edit-permission/{userStore}/{rolename}")) {
matchedElements = uriMatcher.elements();
userStore = matchedElements.userStore;
roleName = matchedElements.rolename;
context["roleName"] = userStore + '/' + roleName;
}
context["roleName"] = request.getParameter("rolename");
return context;
}

@ -109,7 +109,7 @@ $(document).ready(function () {
}
var serviceUrl = apiBasePath + "/roles/" +encodeURIComponent(roleName)+"/permissions";
if (userStore) {
serviceUrl += "?user-store=" + userStore;
serviceUrl += "?user-store=" + encodeURIComponent(userStore);
}
$.registerPartial("list", listPartialSrc, function(){
$.template("treeTemplate", treeTemplateSrc, function (template) {
@ -158,14 +158,14 @@ $(document).ready(function () {
userStore = roleName.substr(0, roleName.indexOf('/'));
roleName = roleName.substr(roleName.indexOf('/') + 1);
}
var updateRolePermissionAPI = apiBasePath + "/roles/" + roleName;
var updateRolePermissionAPI = apiBasePath + "/roles/" + encodeURIComponent(roleName);
var updateRolePermissionData = {};
var perms = [];
$("#permissionList li input:checked").each(function(){
perms.push($(this).data("resourcepath"));
});
if (userStore) {
updateRolePermissionAPI += "?user-store=" + userStore;
updateRolePermissionAPI += "?user-store=" + encodeURIComponent(userStore);
updateRolePermissionData.roleName = userStore + "/" + roleName;
} else {
updateRolePermissionData.roleName = roleName;

@ -131,7 +131,8 @@ $(document).ready(function () {
data: function (params) {
var postData = {};
postData.actionMethod = "GET";
postData.actionUrl = apiBasePath + "/users/search/usernames?filter=" + params.term + "&domain=" + domain;
postData.actionUrl = apiBasePath + "/users/search/usernames?filter=" + params.term + "&domain=" +
encodeURIComponent(domain);
postData.actionPayload = null;
return JSON.stringify(postData);
},
@ -182,10 +183,10 @@ $(document).ready(function () {
} else {
var addRoleFormData = {};
addRoleFormData.roleName = roleName;
var addRoleAPI = apiBasePath + "/roles/" + currentRoleName;
var addRoleAPI = apiBasePath + "/roles/" + encodeURIComponent(currentRoleName);
if (domain != "PRIMARY"){
addRoleFormData.roleName = domain + "/" + roleName;
addRoleAPI = addRoleAPI + "?user-store=" + domain;
addRoleAPI = addRoleAPI + "?user-store=" + encodeURIComponent(domain);
}
invokerUtil.put(
addRoleAPI,

Loading…
Cancel
Save