From a71d6562ca86ce651fe084e065022253f3311a4d Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sun, 8 Jan 2023 11:59:29 +0100 Subject: [PATCH] Remove function useless --- .../covas/Resources/PublisherRessources.java | 79 +------------------ 1 file changed, 4 insertions(+), 75 deletions(-) diff --git a/src/main/java/com/covas/Resources/PublisherRessources.java b/src/main/java/com/covas/Resources/PublisherRessources.java index 8782c35..bb9ca51 100644 --- a/src/main/java/com/covas/Resources/PublisherRessources.java +++ b/src/main/java/com/covas/Resources/PublisherRessources.java @@ -267,30 +267,9 @@ public class PublisherRessources { } // Delete - @DELETE - @RolesAllowed("User") - @Transactional - public Response changeStatusToDelete(@Context SecurityContext ctx, @CookieParam("user") String userCookie) { - UUID kid = UUID.fromString(jwt.getClaim(Claims.kid)); - UsersEntity user = UsersEntity.findById(kid); - - Response.Status status = getResponseCheck(ctx, userCookie, user); - - if (status.equals(Response.Status.OK)) { - user.status = -1; - user.updated_at = LocalDateTime.now(); - user.deleted_at = LocalDateTime.now(); - user.persist(); - if (!user.isPersistent()) { - status = Response.Status.NOT_MODIFIED; - } - } - return Response.status(status).build(); - } - @DELETE @Path("{id}") - @RolesAllowed("Admin") + @RolesAllowed({"Admin", "User"}) @Transactional public Response changeStatusSinglePublisherToDelete(@Context SecurityContext ctx, @CookieParam("user") String userCookie, @PathParam("id") String id) { @@ -314,33 +293,9 @@ public class PublisherRessources { return Response.status(status).build(); } - - - @DELETE - @RolesAllowed("User") - @Transactional - @Path("disable") - public Response changeStatusToDisable(@Context SecurityContext ctx, @CookieParam("user") String userCookie) { - UUID kid = UUID.fromString(jwt.getClaim(Claims.kid)); - UsersEntity user = UsersEntity.findById(kid); - - Response.Status status = getResponseCheck(ctx, userCookie, user); - - if (status.equals(Response.Status.OK)) { - user.status = -1; - user.updated_at = LocalDateTime.now(); - user.deleted_at = LocalDateTime.now(); - user.persist(); - if (!user.isPersistent()) { - status = Response.Status.NOT_MODIFIED; - } - } - return Response.status(status).build(); - } - @DELETE @Path("/disable/{id}") - @RolesAllowed("Admin") + @RolesAllowed({"Admin", "User"}) @Transactional public Response changeStatusSinglePublisherToDisable(@Context SecurityContext ctx, @CookieParam("user") String userCookie, @PathParam("id") String id) { @@ -366,7 +321,7 @@ public class PublisherRessources { // PATCH @PATCH - @RolesAllowed("Admin") + @RolesAllowed({"Admin", "User"}) @Consumes(MediaType.APPLICATION_JSON) @Transactional @Path("{id}") @@ -404,7 +359,7 @@ public class PublisherRessources { @PATCH - @RolesAllowed("Admin") + @RolesAllowed({"Admin", "User"}) @Consumes(MediaType.APPLICATION_JSON) @Transactional @Path("enable/{id}") @@ -428,30 +383,4 @@ public class PublisherRessources { return Response.status(status).build(); } - @PATCH - @RolesAllowed("User") - @Consumes(MediaType.APPLICATION_JSON) - @Transactional - public Response updateSingleUser(@Context SecurityContext ctx, @CookieParam("user") String userCookie, - UsersEntity users) { - UUID kid = UUID.fromString(jwt.getClaim(Claims.kid)); - UsersEntity user = UsersEntity.findById(kid); - Response.Status status = getResponseCheck(ctx, userCookie, user); - - if (status.equals(Response.Status.OK)) { - - user.name = users.name; - user.firstName = users.firstName; - user.email = users.email; - user.birth = LocalDate.of(users.birth.getYear(), users.birth.getMonth(), - users.birth.getDayOfMonth()); - user.updated_at = LocalDateTime.now(); - user.password = Hash.encryptSHA512(Base64.toBase64String(users.password.getBytes(StandardCharsets.UTF_8))); - user.persist(); - if (!user.isPersistent()) { - status = Response.Status.NOT_MODIFIED; - } - } - return Response.status(status).build(); - } }