add useraccounts resource which is responsible for supporting capabilities that allow a user update their account details.
This commit is contained in:
@@ -2,7 +2,6 @@ package org.mifosng.ui;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosng.data.AppUserData;
|
||||
import org.mifosng.data.ClientData;
|
||||
import org.mifosng.data.ClientDataWithAccountsData;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
@@ -17,7 +16,6 @@ import org.mifosng.data.PermissionData;
|
||||
import org.mifosng.data.RoleData;
|
||||
import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.data.command.ChangePasswordCommand;
|
||||
import org.mifosng.data.command.EnrollClientCommand;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
import org.mifosng.data.command.LoanTransactionCommand;
|
||||
@@ -35,10 +33,6 @@ public interface CommonRestOperations {
|
||||
|
||||
void updateProtectedResource(ProtectedResourceDetails loadProtectedResourceDetailsById);
|
||||
|
||||
AppUserData retrieveCurrentUser();
|
||||
|
||||
EntityIdentifier updateCurrentUserPassword(ChangePasswordCommand command);
|
||||
|
||||
Collection<RoleData> retrieveAllRoles();
|
||||
|
||||
RoleData retrieveRole(Long roleId);
|
||||
|
||||
-44
@@ -6,7 +6,6 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosng.configuration.ApplicationConfigurationService;
|
||||
import org.mifosng.data.AppUserData;
|
||||
import org.mifosng.data.ClientData;
|
||||
import org.mifosng.data.ClientDataWithAccountsData;
|
||||
import org.mifosng.data.ClientList;
|
||||
@@ -29,7 +28,6 @@ import org.mifosng.data.RoleData;
|
||||
import org.mifosng.data.RoleList;
|
||||
import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.data.command.ChangePasswordCommand;
|
||||
import org.mifosng.data.command.EnrollClientCommand;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
import org.mifosng.data.command.LoanTransactionCommand;
|
||||
@@ -547,25 +545,6 @@ public class CommonRestOperationsImpl implements CommonRestOperations {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier updateCurrentUserPassword(
|
||||
ChangePasswordCommand command) {
|
||||
try {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/admin/user/current/password"));
|
||||
|
||||
ResponseEntity<EntityIdentifier> s = this.oauthRestServiceTemplate
|
||||
.postForEntity(restUri,
|
||||
createUpdateCurrentUserPasswordRequest(command),
|
||||
EntityIdentifier.class);
|
||||
|
||||
return s.getBody();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
private HttpEntity<UserCommand> createUserRequest(final UserCommand command) {
|
||||
|
||||
HttpHeaders requestHeaders = new HttpHeaders();
|
||||
@@ -577,18 +556,6 @@ public class CommonRestOperationsImpl implements CommonRestOperations {
|
||||
return requestEntity;
|
||||
}
|
||||
|
||||
private HttpEntity<ChangePasswordCommand> createUpdateCurrentUserPasswordRequest(
|
||||
final ChangePasswordCommand command) {
|
||||
|
||||
HttpHeaders requestHeaders = new HttpHeaders();
|
||||
requestHeaders.set("Accept", "application/xml");
|
||||
requestHeaders.set("Content-Type", "application/xml");
|
||||
|
||||
HttpEntity<ChangePasswordCommand> requestEntity = new HttpEntity<ChangePasswordCommand>(
|
||||
command, requestHeaders);
|
||||
return requestEntity;
|
||||
}
|
||||
|
||||
private HttpEntity<RoleCommand> roleRequest(final RoleCommand command) {
|
||||
|
||||
HttpHeaders requestHeaders = new HttpHeaders();
|
||||
@@ -600,17 +567,6 @@ public class CommonRestOperationsImpl implements CommonRestOperations {
|
||||
return requestEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppUserData retrieveCurrentUser() {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/admin/user/current"));
|
||||
|
||||
ResponseEntity<AppUserData> s = this.oauthRestServiceTemplate.exchange(
|
||||
restUri, HttpMethod.GET, emptyRequest(), AppUserData.class);
|
||||
|
||||
return s.getBody();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RoleData> retrieveAllRoles() {
|
||||
try {
|
||||
|
||||
-58
@@ -4,23 +4,14 @@ import java.util.Collection;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.mifosng.data.AppUserData;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.ErrorResponse;
|
||||
import org.mifosng.data.command.ChangePasswordCommand;
|
||||
import org.mifosng.data.command.UserCommand;
|
||||
import org.mifosng.ui.CommonRestOperations;
|
||||
import org.mifosng.ui.loanproduct.ClientValidationException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
/**
|
||||
* Controller for user and organisation administration functions.
|
||||
@@ -28,13 +19,6 @@ import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
@Controller
|
||||
public class AdministrationController {
|
||||
|
||||
private final CommonRestOperations commonRestOperations;
|
||||
|
||||
@Autowired
|
||||
public AdministrationController(final CommonRestOperations commonRestOperations) {
|
||||
this.commonRestOperations = commonRestOperations;
|
||||
}
|
||||
|
||||
@ExceptionHandler(AccessDeniedException.class)
|
||||
public String accessDeniedException() {
|
||||
return "unAuthorizedAction";
|
||||
@@ -63,46 +47,4 @@ public class AdministrationController {
|
||||
public String userSettingsScreen() {
|
||||
return "admin/accountsettings";
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/json", produces="application/json", value = "org/admin/settings/details", method = RequestMethod.GET)
|
||||
public @ResponseBody AppUserData viewUserDetails() {
|
||||
|
||||
return this.commonRestOperations.retrieveCurrentUser();
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "org/admin/settings/details", method = RequestMethod.POST)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public @ResponseBody EntityIdentifier updateUserDetails(
|
||||
@RequestParam(value="username", required=false) String username,
|
||||
@RequestParam(value="firstname", required=false) String firstname,
|
||||
@RequestParam(value="lastname", required=false) String lastname,
|
||||
@RequestParam(value="email", required=false) String email) {
|
||||
|
||||
UserCommand command = new UserCommand();
|
||||
command.setUsername(username);
|
||||
command.setFirstname(firstname);
|
||||
command.setLastname(lastname);
|
||||
command.setEmail(email);
|
||||
|
||||
return this.commonRestOperations.updateCurrentUserDetails(command);
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/json", produces="application/json", value = "org/admin/settings/password", method = RequestMethod.GET)
|
||||
public @ResponseBody ChangePasswordCommand viewChangePasswordDetails() {
|
||||
|
||||
return new ChangePasswordCommand();
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "org/admin/settings/password", method = RequestMethod.POST)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public @ResponseBody EntityIdentifier updateUserDetails(
|
||||
@RequestParam(value="password", required=false) String password,
|
||||
@RequestParam(value="passwordrepeat", required=false) String passwordrepeat) {
|
||||
|
||||
ChangePasswordCommand command = new ChangePasswordCommand();
|
||||
command.setPassword(password);
|
||||
command.setPasswordrepeat(passwordrepeat);
|
||||
|
||||
return this.commonRestOperations.updateCurrentUserPassword(command);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user