Skip to content

Commit

Permalink
Merge pull request #3204 from keeps/alindo-dev-Revoke
Browse files Browse the repository at this point in the history
edited revokeAccessKey
  • Loading branch information
hmiguim authored May 28, 2024
2 parents 9e43a4a + 291a8cc commit 7720284
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,16 @@ public AccessKey createAccessKey(@RequestBody AccessKey accessKey) {
}

@Override
public AccessKey revokeAccessKey(@RequestBody AccessKey accessKey) {
public AccessKey revokeAccessKey(String id) {
final ControllerAssistant controllerAssistant = new ControllerAssistant() {};
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);

LogEntryState state = LogEntryState.SUCCESS;

accessKey.setStatus(AccessKeyStatus.REVOKED);

try {
controllerAssistant.checkRoles(requestContext.getUser());
AccessKey accessKey = RodaCoreFactory.getModelService().retrieveAccessKey(id);
accessKey.setStatus(AccessKeyStatus.REVOKED);
return RodaCoreFactory.getModelService().updateAccessKey(accessKey, requestContext.getUser().getName());
} catch (RODAException e) {
state = LogEntryState.FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void buttonRevokeHandler(ClickEvent e) {
public void onSuccess(Boolean confirm) {
if (confirm) {
Services services = new Services("Revoke access key", "revoke");
services.membersResource(s -> s.revokeAccessKey(accessKey)).whenComplete((accessKey, error) -> {
services.membersResource(s -> s.revokeAccessKey(accessKey.getId())).whenComplete((accessKey, error) -> {
if (accessKey != null) {
refresh();
Toast.showInfo(messages.accessKeyLabel(), messages.accessKeySuccessfullyRevoked());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ AccessKey regenerateAccessKey(
AccessKey createAccessKey(
@Parameter(name = "accesskey", required = true, content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)) AccessKey accessKey);

@RequestMapping(path = "/accesskey/revoke", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Revoke access key", requestBody = @RequestBody(required = true, content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = AccessKey.class))), description = "Revokes a access key", responses = {
@RequestMapping(path = "/users/access-keys/revoke/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Revoke access key", description = "Revokes a access key", responses = {
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = AccessKey.class))),
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))})
AccessKey revokeAccessKey(
@Parameter(name = "accesskey", required = true, content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)) AccessKey accessKey);
@Parameter(description = "The access key id") @PathVariable(name = "id") String id);
}

0 comments on commit 7720284

Please sign in to comment.