Return clients just for self service API call (FINERACT-1340)

This commit is contained in:
Joseph Makara
2021-04-15 22:00:29 +08:00
committed by Petri Tuomola
parent 870bab22fc
commit fb14a38ed6
2 changed files with 6 additions and 3 deletions
@@ -31,9 +31,11 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Set;
import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.core.serialization.ToApiJsonSerializer;
@@ -94,7 +96,8 @@ public class AuthenticationApiResource {
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = AuthenticationApiResourceSwagger.PostAuthenticationResponse.class))),
@ApiResponse(responseCode = "400", description = "Unauthenticated. Please login") })
public String authenticate(final String apiRequestBodyAsJson) {
public String authenticate(final String apiRequestBodyAsJson,
@QueryParam("returnClientList") @DefaultValue("false") boolean returnClientList) {
// TODO FINERACT-819: sort out Jersey so JSON conversion does not have
// to be done explicitly via GSON here, but implicit by arg
AuthenticateRequest request = new Gson().fromJson(apiRequestBodyAsJson, AuthenticateRequest.class);
@@ -147,7 +150,7 @@ public class AuthenticationApiResource {
authenticatedUserData = new AuthenticatedUserData(request.username, officeId, officeName, staffId, staffDisplayName,
organisationalRole, roles, permissions, principal.getId(),
new String(base64EncodedAuthenticationKey, StandardCharsets.UTF_8), isTwoFactorRequired,
principal.isSelfServiceUser() ? clientReadPlatformService.retrieveUserClients(userId) : null);
returnClientList ? clientReadPlatformService.retrieveUserClients(userId) : null);
}
}
@@ -57,6 +57,6 @@ public class SelfAuthenticationApiResource {
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = SelfAuthenticationApiResourceSwagger.PostSelfAuthenticationResponse.class))) })
public String authenticate(final String apiRequestBodyAsJson) {
return this.authenticationApiResource.authenticate(apiRequestBodyAsJson);
return this.authenticationApiResource.authenticate(apiRequestBodyAsJson, true);
}
}