remove path for put method

This commit is contained in:
Valentin CZERYBA 2022-08-12 22:18:25 +02:00
parent a147315851
commit f64640db45

View File

@ -180,11 +180,10 @@ public class UsersRessources {
// PUT // PUT
@PUT @PUT
@Path("{pseudo}")
@RolesAllowed("Admin") @RolesAllowed("Admin")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Transactional @Transactional
public Response addUser(@Context SecurityContext ctx, @CookieParam("user") String userCookie, @PathParam("pseudo") String pseudo, public Response addUser(@Context SecurityContext ctx, @CookieParam("user") String userCookie,
UsersEntity users) { UsersEntity users) {
UUID kid = UUID.fromString(jwt.getClaim(Claims.kid)); UUID kid = UUID.fromString(jwt.getClaim(Claims.kid));
UsersEntity user = UsersEntity.findById(kid); UsersEntity user = UsersEntity.findById(kid);
@ -192,13 +191,13 @@ public class UsersRessources {
if (status.equals(Response.Status.OK)) { if (status.equals(Response.Status.OK)) {
UsersEntity usersOrig = UsersEntity.findByPseudo(pseudo); UsersEntity usersOrig = UsersEntity.findByPseudo(users.pseudo);
if (usersOrig != null) { if (usersOrig != null) {
status = Response.Status.UNAUTHORIZED; status = Response.Status.UNAUTHORIZED;
} else { } else {
UsersEntity usersNew = new UsersEntity(); UsersEntity usersNew = new UsersEntity();
usersNew.name = users.name; usersNew.name = users.name;
usersNew.pseudo = pseudo; usersNew.pseudo = users.pseudo;
usersNew.firstName = users.firstName; usersNew.firstName = users.firstName;
usersNew.email = users.email; usersNew.email = users.email;
usersNew.birth = LocalDate.of(users.birth.getYear(), users.birth.getMonth(), usersNew.birth = LocalDate.of(users.birth.getYear(), users.birth.getMonth(),
@ -208,7 +207,7 @@ public class UsersRessources {
usersNew.password = Hash usersNew.password = Hash
.encryptSHA512(Base64.toBase64String(users.password.getBytes(StandardCharsets.UTF_8))); .encryptSHA512(Base64.toBase64String(users.password.getBytes(StandardCharsets.UTF_8)));
usersNew.roles = users.roles; usersNew.roles = users.roles;
usersNew.status = 2; usersNew.status = 1;
usersNew.persist(); usersNew.persist();
if (usersNew.isPersistent()) { if (usersNew.isPersistent()) {
status = Response.Status.CREATED; status = Response.Status.CREATED;