From 8625dd44e70ad577aad01642cd6493127e7e8590 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Wed, 20 Jul 2022 23:36:02 +0200 Subject: [PATCH] nouveaux erreurs --- src/main/java/com/covas/Entity/UsersEntity.java | 2 +- src/main/java/com/covas/Resources/TokenRessource.java | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/covas/Entity/UsersEntity.java b/src/main/java/com/covas/Entity/UsersEntity.java index 1f1d2e9..2f4f302 100644 --- a/src/main/java/com/covas/Entity/UsersEntity.java +++ b/src/main/java/com/covas/Entity/UsersEntity.java @@ -64,7 +64,7 @@ public class UsersEntity extends PanacheEntityBase { users.name = name; users.firstName = firstName; users.birth = birth; - users.status = false; + users.status = true; users.password = Hash.encryptSHA512(password); users.roles = roles; users.created_at = LocalDateTime.now(); diff --git a/src/main/java/com/covas/Resources/TokenRessource.java b/src/main/java/com/covas/Resources/TokenRessource.java index ad37588..8e3322e 100644 --- a/src/main/java/com/covas/Resources/TokenRessource.java +++ b/src/main/java/com/covas/Resources/TokenRessource.java @@ -59,8 +59,11 @@ public class TokenRessource { return Response.status(Response.Status.NOT_FOUND).build(); } if (jwtCookie == null) { - if((!password.equals(users.password)) && (!users.status)) { - return Response.status(Response.Status.FORBIDDEN).build(); + if(!password.equals(users.password)) { + return Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + if(!users.status){ + return Response.status(Response.Status.FORBIDDEN).build(); } // Create a JWT token signed using the 'HS256' algorithm String newJwtCookie = Jwt.issuer("https://example.com/issuer").upn(name).groups(users.roles).claim(Claims.kid, users.id.toString()).expiresIn(Duration.ofMinutes(1)).sign(); @@ -74,7 +77,7 @@ public class TokenRessource { jwt = parser.parse(jwtCookie); } catch(ParseException p){ - return Response.status(Response.Status.NOT_ACCEPTABLE).build(); + return Response.status(Response.Status.GONE).build(); } // or jwt = parser.decrypt(jwtCookie, secret); String kid = jwt.getClaim(Claims.kid).toString();