From 6a7e8b056374ede39ddeeefe456364f8a735909c Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Thu, 11 Aug 2022 00:11:49 +0200 Subject: [PATCH] add pathparam --- src/main/java/com/covas/Resources/UsersRessources.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/covas/Resources/UsersRessources.java b/src/main/java/com/covas/Resources/UsersRessources.java index 122fe7d..00a7461 100644 --- a/src/main/java/com/covas/Resources/UsersRessources.java +++ b/src/main/java/com/covas/Resources/UsersRessources.java @@ -323,15 +323,16 @@ public class UsersRessources { @RolesAllowed("Admin") @Consumes(MediaType.APPLICATION_JSON) @Transactional + @Path("{id}") public Response updateUserAdmin(@Context SecurityContext ctx, @CookieParam("user") String userCookie, - UsersEntity users) { + UsersEntity users, @PathParam("id") String id) { 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)) { - UsersEntity usersOrig = UsersEntity.findByPseudo(users.pseudo); + UsersEntity usersOrig = UsersEntity.findById(UUID.fromString(id)); if (usersOrig == null) { status = Response.Status.NOT_FOUND; } else { @@ -341,8 +342,10 @@ public class UsersRessources { usersOrig.birth = LocalDate.of(users.birth.getYear(), users.birth.getMonth(), users.birth.getDayOfMonth()); usersOrig.updated_at = LocalDateTime.now(); - usersOrig.password = Hash + if(users.password.length() > 0){ + usersOrig.password = Hash .encryptSHA512(Base64.toBase64String(users.password.getBytes(StandardCharsets.UTF_8))); + } usersOrig.roles = users.roles; if(users.status == 1){ usersOrig.deleted_at = null;