mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge pull request #370 from Megala21/master
Fixing EMM-1596 and EMM-1683
This commit is contained in:
commit
d09475669e
@ -142,6 +142,11 @@ public interface UserManagementService {
|
|||||||
value = "Username of the user to be fetched.",
|
value = "Username of the user to be fetched.",
|
||||||
required = true)
|
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,
|
||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "If-Modified-Since",
|
name = "If-Modified-Since",
|
||||||
value = "Validates if the requested variant has not been modified since the time specified",
|
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.",
|
value = "Username of the user to be updated.",
|
||||||
required = true)
|
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,
|
||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "userData",
|
name = "userData",
|
||||||
value = "User related details.",
|
value = "User related details.",
|
||||||
@ -230,7 +240,12 @@ public interface UserManagementService {
|
|||||||
@Permission(name = "Manage Users", permission = "/device-mgt/users/manage")
|
@Permission(name = "Manage Users", permission = "/device-mgt/users/manage")
|
||||||
Response removeUser(
|
Response removeUser(
|
||||||
@ApiParam(name = "username", value = "Username of the user to be deleted.", required = true)
|
@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
|
@GET
|
||||||
@Path("/{username}/roles")
|
@Path("/{username}/roles")
|
||||||
@ -279,7 +294,12 @@ public interface UserManagementService {
|
|||||||
@Permission(name = "View Users", permission = "/device-mgt/users/view")
|
@Permission(name = "View Users", permission = "/device-mgt/users/view")
|
||||||
Response getRolesOfUser(
|
Response getRolesOfUser(
|
||||||
@ApiParam(name = "username", value = "Username of the user.", required = true)
|
@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
|
@GET
|
||||||
@ApiOperation(
|
@ApiOperation(
|
||||||
|
|||||||
@ -78,6 +78,11 @@ public interface UserManagementAdminService {
|
|||||||
@PathParam("username")
|
@PathParam("username")
|
||||||
@Size(max = 45)
|
@Size(max = 45)
|
||||||
String username,
|
String username,
|
||||||
|
@ApiParam(
|
||||||
|
name = "domain",
|
||||||
|
value = "Domain name of the user store.",
|
||||||
|
required = false)
|
||||||
|
@QueryParam("domain") String domain,
|
||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "credentials",
|
name = "credentials",
|
||||||
value = "Credential.",
|
value = "Credential.",
|
||||||
|
|||||||
@ -105,8 +105,11 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
@GET
|
@GET
|
||||||
@Path("/{username}")
|
@Path("/{username}")
|
||||||
@Override
|
@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) {
|
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
||||||
|
if (domain != null && !domain.isEmpty()) {
|
||||||
|
username = domain + '/' + username;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||||
if (!userStoreManager.isExistingUser(username)) {
|
if (!userStoreManager.isExistingUser(username)) {
|
||||||
@ -131,7 +134,10 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
@PUT
|
@PUT
|
||||||
@Path("/{username}")
|
@Path("/{username}")
|
||||||
@Override
|
@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 {
|
try {
|
||||||
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||||
if (!userStoreManager.isExistingUser(username)) {
|
if (!userStoreManager.isExistingUser(username)) {
|
||||||
@ -205,7 +211,10 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("/{username}")
|
@Path("/{username}")
|
||||||
@Override
|
@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 {
|
try {
|
||||||
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||||
if (!userStoreManager.isExistingUser(username)) {
|
if (!userStoreManager.isExistingUser(username)) {
|
||||||
@ -233,7 +242,10 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
@GET
|
@GET
|
||||||
@Path("/{username}/roles")
|
@Path("/{username}/roles")
|
||||||
@Override
|
@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 {
|
try {
|
||||||
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||||
if (!userStoreManager.isExistingUser(username)) {
|
if (!userStoreManager.isExistingUser(username)) {
|
||||||
|
|||||||
@ -37,7 +37,10 @@ public class UserManagementAdminServiceImpl implements UserManagementAdminServic
|
|||||||
@Override
|
@Override
|
||||||
public Response resetUserPassword(@PathParam("username")
|
public Response resetUserPassword(@PathParam("username")
|
||||||
@Size(max = 45)
|
@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);
|
return CredentialManagementResponseBuilder.buildResetPasswordResponse(user, credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -177,10 +177,18 @@ var userModule = function () {
|
|||||||
*/
|
*/
|
||||||
publicMethods.getUser = function (username) {
|
publicMethods.getUser = function (username) {
|
||||||
var carbonUser = privateMethods.getCarbonUser();
|
var carbonUser = privateMethods.getCarbonUser();
|
||||||
|
var domain;
|
||||||
|
if (username.indexOf('/') > 0) {
|
||||||
|
domain = username.substr(0, username.indexOf('/'));
|
||||||
|
username = username.substr(username.indexOf('/') + 1);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
utility.startTenantFlow(carbonUser);
|
utility.startTenantFlow(carbonUser);
|
||||||
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users/" +
|
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users/" +
|
||||||
encodeURIComponent(username);
|
encodeURIComponent(username);
|
||||||
|
if (domain) {
|
||||||
|
url += '?domain=' + domain;
|
||||||
|
}
|
||||||
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
|
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
|
||||||
response["content"] = parse(response.content);
|
response["content"] = parse(response.content);
|
||||||
response["userDomain"] = carbonUser.domain;
|
response["userDomain"] = carbonUser.domain;
|
||||||
@ -199,10 +207,18 @@ var userModule = function () {
|
|||||||
*/
|
*/
|
||||||
publicMethods.getRolesByUsername = function (username) {
|
publicMethods.getRolesByUsername = function (username) {
|
||||||
var carbonUser = privateMethods.getCarbonUser();
|
var carbonUser = privateMethods.getCarbonUser();
|
||||||
|
var domain;
|
||||||
|
if (username.indexOf('/') > 0) {
|
||||||
|
domain = username.substr(0, username.indexOf('/'));
|
||||||
|
username = username.substr(username.indexOf('/') + 1);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
utility.startTenantFlow(carbonUser);
|
utility.startTenantFlow(carbonUser);
|
||||||
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users/" +
|
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users/" +
|
||||||
encodeURIComponent(username) + "/roles";
|
encodeURIComponent(username) + "/roles";
|
||||||
|
if (domain) {
|
||||||
|
url += '?domain=' + domain;
|
||||||
|
}
|
||||||
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
|
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
|
||||||
if (response.status == "success") {
|
if (response.status == "success") {
|
||||||
response.content = parse(response.content).roles;
|
response.content = parse(response.content).roles;
|
||||||
|
|||||||
@ -235,8 +235,8 @@ $(document).ready(function () {
|
|||||||
roles = [];
|
roles = [];
|
||||||
}
|
}
|
||||||
addUserFormData.roles = roles;
|
addUserFormData.roles = roles;
|
||||||
|
username = username.substr(username.indexOf('/') + 1);
|
||||||
var addUserAPI = deviceMgtBasePath + "/users/" + username;
|
var addUserAPI = deviceMgtBasePath + "/users/" + username + "?domain=" + domain;
|
||||||
|
|
||||||
invokerUtil.put(
|
invokerUtil.put(
|
||||||
addUserAPI,
|
addUserAPI,
|
||||||
|
|||||||
@ -162,9 +162,15 @@ function resetPassword(username) {
|
|||||||
} else {
|
} else {
|
||||||
var resetPasswordFormData = {};
|
var resetPasswordFormData = {};
|
||||||
resetPasswordFormData.newPassword = unescape(confirmedPassword);
|
resetPasswordFormData.newPassword = unescape(confirmedPassword);
|
||||||
|
var domain;
|
||||||
var resetPasswordServiceURL = apiBasePath + "/admin/users/"+ username +"/credentials";
|
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(
|
invokerUtil.post(
|
||||||
resetPasswordServiceURL,
|
resetPasswordServiceURL,
|
||||||
resetPasswordFormData,
|
resetPasswordFormData,
|
||||||
@ -198,7 +204,15 @@ function resetPassword(username) {
|
|||||||
* on User Listing page in WSO2 MDM Console.
|
* on User Listing page in WSO2 MDM Console.
|
||||||
*/
|
*/
|
||||||
function removeUser(username) {
|
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;
|
var removeUserAPI = apiBasePath + "/users/" + username;
|
||||||
|
if (domain) {
|
||||||
|
removeUserAPI += '?domain=' + domain;
|
||||||
|
}
|
||||||
$(modalPopupContent).html($('#remove-user-modal-content').html());
|
$(modalPopupContent).html($('#remove-user-modal-content').html());
|
||||||
showPopup();
|
showPopup();
|
||||||
|
|
||||||
@ -207,7 +221,11 @@ function removeUser(username) {
|
|||||||
removeUserAPI,
|
removeUserAPI,
|
||||||
function (data, textStatus, jqXHR) {
|
function (data, textStatus, jqXHR) {
|
||||||
if (jqXHR.status == 200) {
|
if (jqXHR.status == 200) {
|
||||||
|
if (domain) {
|
||||||
|
$("#user-" + domain + "\\/" + username).remove();
|
||||||
|
} else {
|
||||||
$("#user-" + username).remove();
|
$("#user-" + username).remove();
|
||||||
|
}
|
||||||
// update modal-content with success message
|
// update modal-content with success message
|
||||||
$(modalPopupContent).html($('#remove-user-success-content').html());
|
$(modalPopupContent).html($('#remove-user-success-content').html());
|
||||||
$("a#remove-user-success-link").click(function () {
|
$("a#remove-user-success-link").click(function () {
|
||||||
|
|||||||
@ -66,9 +66,7 @@ $(document).ready(function () {
|
|||||||
var changePasswordFormData = {};
|
var changePasswordFormData = {};
|
||||||
changePasswordFormData["oldPassword"] = unescape((currentPassword));
|
changePasswordFormData["oldPassword"] = unescape((currentPassword));
|
||||||
changePasswordFormData["newPassword"] = unescape((newPassword));
|
changePasswordFormData["newPassword"] = unescape((newPassword));
|
||||||
|
var changePasswordAPI = "/api/device-mgt/v1.0/users/credentials";
|
||||||
var changePasswordAPI = "/api/device-mgt/v1.0/users/" + user + "/credentials";
|
|
||||||
|
|
||||||
invokerUtil.put(
|
invokerUtil.put(
|
||||||
changePasswordAPI,
|
changePasswordAPI,
|
||||||
changePasswordFormData,
|
changePasswordFormData,
|
||||||
|
|||||||
@ -46,7 +46,7 @@
|
|||||||
</li>
|
</li>
|
||||||
|
|
||||||
<div id="change-password-window" class="hide">
|
<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">
|
<div class="modal-header">
|
||||||
<h4 class="pull-left modal-title">
|
<h4 class="pull-left modal-title">
|
||||||
<span class="fw-stack">
|
<span class="fw-stack">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user