Merge pull request #370 from Megala21/master

Fixing EMM-1596 and EMM-1683
revert-70aa11f8
Harshan Liyanage 8 years ago committed by GitHub
commit d09475669e

@ -142,6 +142,11 @@ public interface UserManagementService {
value = "Username of the user to be fetched.",
required = true)
@PathParam("username") String username,
@ApiParam(
name = "domain",
value = "Domain name of the user store.",
required = false)
@QueryParam("domain") String domain,
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
@ -199,6 +204,11 @@ public interface UserManagementService {
value = "Username of the user to be updated.",
required = true)
@PathParam("username") String username,
@ApiParam(
name = "domain",
value = "Domain name of the user store.",
required = false)
@QueryParam("domain") String domain,
@ApiParam(
name = "userData",
value = "User related details.",
@ -230,7 +240,12 @@ public interface UserManagementService {
@Permission(name = "Manage Users", permission = "/device-mgt/users/manage")
Response removeUser(
@ApiParam(name = "username", value = "Username of the user to be deleted.", required = true)
@PathParam("username") String username);
@PathParam("username") String username,
@ApiParam(
name = "domain",
value = "Domain name of the user store.",
required = false)
@QueryParam("domain") String domain);
@GET
@Path("/{username}/roles")
@ -279,7 +294,12 @@ public interface UserManagementService {
@Permission(name = "View Users", permission = "/device-mgt/users/view")
Response getRolesOfUser(
@ApiParam(name = "username", value = "Username of the user.", required = true)
@PathParam("username") String username);
@PathParam("username") String username,
@ApiParam(
name = "domain",
value = "Domain name of the user store.",
required = false)
@QueryParam("domain") String domain);
@GET
@ApiOperation(

@ -78,6 +78,11 @@ public interface UserManagementAdminService {
@PathParam("username")
@Size(max = 45)
String username,
@ApiParam(
name = "domain",
value = "Domain name of the user store.",
required = false)
@QueryParam("domain") String domain,
@ApiParam(
name = "credentials",
value = "Credential.",

@ -105,8 +105,11 @@ public class UserManagementServiceImpl implements UserManagementService {
@GET
@Path("/{username}")
@Override
public Response getUser(@PathParam("username") String username,
public Response getUser(@PathParam("username") String username, @QueryParam("domain") String domain,
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
if (domain != null && !domain.isEmpty()) {
username = domain + '/' + username;
}
try {
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
if (!userStoreManager.isExistingUser(username)) {
@ -131,7 +134,10 @@ public class UserManagementServiceImpl implements UserManagementService {
@PUT
@Path("/{username}")
@Override
public Response updateUser(@PathParam("username") String username, UserInfo userInfo) {
public Response updateUser(@PathParam("username") String username, @QueryParam("domain") String domain, UserInfo userInfo) {
if (domain != null && !domain.isEmpty()) {
username = domain + '/' + username;
}
try {
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
if (!userStoreManager.isExistingUser(username)) {
@ -205,7 +211,10 @@ public class UserManagementServiceImpl implements UserManagementService {
@DELETE
@Path("/{username}")
@Override
public Response removeUser(@PathParam("username") String username) {
public Response removeUser(@PathParam("username") String username, @QueryParam("domain") String domain) {
if (domain != null && !domain.isEmpty()) {
username = domain + '/' + username;
}
try {
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
if (!userStoreManager.isExistingUser(username)) {
@ -233,7 +242,10 @@ public class UserManagementServiceImpl implements UserManagementService {
@GET
@Path("/{username}/roles")
@Override
public Response getRolesOfUser(@PathParam("username") String username) {
public Response getRolesOfUser(@PathParam("username") String username, @QueryParam("domain") String domain) {
if (domain != null && !domain.isEmpty()) {
username = domain + '/' + username;
}
try {
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
if (!userStoreManager.isExistingUser(username)) {

@ -37,7 +37,10 @@ public class UserManagementAdminServiceImpl implements UserManagementAdminServic
@Override
public Response resetUserPassword(@PathParam("username")
@Size(max = 45)
String user, PasswordResetWrapper credentials) {
String user, @QueryParam("domain") String domain, PasswordResetWrapper credentials) {
if (domain != null && !domain.isEmpty()) {
user = domain + '/' + user;
}
return CredentialManagementResponseBuilder.buildResetPasswordResponse(user, credentials);
}

@ -177,10 +177,18 @@ var userModule = function () {
*/
publicMethods.getUser = function (username) {
var carbonUser = privateMethods.getCarbonUser();
var domain;
if (username.indexOf('/') > 0) {
domain = username.substr(0, username.indexOf('/'));
username = username.substr(username.indexOf('/') + 1);
}
try {
utility.startTenantFlow(carbonUser);
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users/" +
encodeURIComponent(username);
if (domain) {
url += '?domain=' + domain;
}
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
response["content"] = parse(response.content);
response["userDomain"] = carbonUser.domain;
@ -199,10 +207,18 @@ var userModule = function () {
*/
publicMethods.getRolesByUsername = function (username) {
var carbonUser = privateMethods.getCarbonUser();
var domain;
if (username.indexOf('/') > 0) {
domain = username.substr(0, username.indexOf('/'));
username = username.substr(username.indexOf('/') + 1);
}
try {
utility.startTenantFlow(carbonUser);
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users/" +
encodeURIComponent(username) + "/roles";
if (domain) {
url += '?domain=' + domain;
}
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
if (response.status == "success") {
response.content = parse(response.content).roles;

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

@ -162,9 +162,15 @@ function resetPassword(username) {
} else {
var resetPasswordFormData = {};
resetPasswordFormData.newPassword = unescape(confirmedPassword);
var resetPasswordServiceURL = apiBasePath + "/admin/users/"+ username +"/credentials";
var domain;
if (username.indexOf('/') > 0) {
domain = username.substr(0, username.indexOf('/'));
username = username.substr(username.indexOf('/') + 1);
}
var resetPasswordServiceURL = apiBasePath + "/admin/users/" + username + "/credentials";
if (domain) {
resetPasswordServiceURL += '?domain=' + domain;
}
invokerUtil.post(
resetPasswordServiceURL,
resetPasswordFormData,
@ -198,7 +204,15 @@ function resetPassword(username) {
* on User Listing page in WSO2 MDM Console.
*/
function removeUser(username) {
var domain;
if (username.indexOf('/') > 0) {
domain = username.substr(0, username.indexOf('/'));
username = username.substr(username.indexOf('/') + 1);
}
var removeUserAPI = apiBasePath + "/users/" + username;
if (domain) {
removeUserAPI += '?domain=' + domain;
}
$(modalPopupContent).html($('#remove-user-modal-content').html());
showPopup();
@ -207,7 +221,11 @@ function removeUser(username) {
removeUserAPI,
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200) {
$("#user-" + username).remove();
if (domain) {
$("#user-" + domain + "\\/" + username).remove();
} else {
$("#user-" + username).remove();
}
// update modal-content with success message
$(modalPopupContent).html($('#remove-user-success-content').html());
$("a#remove-user-success-link").click(function () {

@ -66,9 +66,7 @@ $(document).ready(function () {
var changePasswordFormData = {};
changePasswordFormData["oldPassword"] = unescape((currentPassword));
changePasswordFormData["newPassword"] = unescape((newPassword));
var changePasswordAPI = "/api/device-mgt/v1.0/users/" + user + "/credentials";
var changePasswordAPI = "/api/device-mgt/v1.0/users/credentials";
invokerUtil.put(
changePasswordAPI,
changePasswordFormData,

@ -46,7 +46,7 @@
</li>
<div id="change-password-window" class="hide">
<input type="hidden" id="user" value="{{username}}">
<input type="hidden" id="user" value="{{@user.username}}">
<div class="modal-header">
<h4 class="pull-left modal-title">
<span class="fw-stack">

Loading…
Cancel
Save