add pathparam

This commit is contained in:
Valentin CZERYBA 2022-08-11 00:11:49 +02:00
parent dfe75ea040
commit 6a7e8b0563

View File

@ -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;