From 291a8cc93a2a3dbe9ba7095520b54166e7e49dfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Lindo?= Date: Thu, 23 May 2024 10:52:57 +0100 Subject: [PATCH] edited revokeAccessKey --- .../org/roda/wui/api/v2/controller/MembersController.java | 6 +++--- .../roda/wui/client/management/access/ShowAccessKey.java | 2 +- .../org/roda/wui/client/services/MembersRestService.java | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/MembersController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/MembersController.java index d76c32ad9e..0523e95609 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/MembersController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/MembersController.java @@ -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; diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/management/access/ShowAccessKey.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/management/access/ShowAccessKey.java index ad14f76a9a..bde40e3fc3 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/management/access/ShowAccessKey.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/management/access/ShowAccessKey.java @@ -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()); diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/MembersRestService.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/MembersRestService.java index a3b4273286..1688fbf3da 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/MembersRestService.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/MembersRestService.java @@ -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); }