nouveaux erreurs

This commit is contained in:
Valentin CZERYBA 2022-07-20 23:36:02 +02:00
parent da6a38f66e
commit 8625dd44e7
2 changed files with 7 additions and 4 deletions

View File

@ -64,7 +64,7 @@ public class UsersEntity extends PanacheEntityBase {
users.name = name; users.name = name;
users.firstName = firstName; users.firstName = firstName;
users.birth = birth; users.birth = birth;
users.status = false; users.status = true;
users.password = Hash.encryptSHA512(password); users.password = Hash.encryptSHA512(password);
users.roles = roles; users.roles = roles;
users.created_at = LocalDateTime.now(); users.created_at = LocalDateTime.now();

View File

@ -59,8 +59,11 @@ public class TokenRessource {
return Response.status(Response.Status.NOT_FOUND).build(); return Response.status(Response.Status.NOT_FOUND).build();
} }
if (jwtCookie == null) { if (jwtCookie == null) {
if((!password.equals(users.password)) && (!users.status)) { if(!password.equals(users.password)) {
return Response.status(Response.Status.FORBIDDEN).build(); 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 // 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(); 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); jwt = parser.parse(jwtCookie);
} }
catch(ParseException p){ catch(ParseException p){
return Response.status(Response.Status.NOT_ACCEPTABLE).build(); return Response.status(Response.Status.GONE).build();
} }
// or jwt = parser.decrypt(jwtCookie, secret); // or jwt = parser.decrypt(jwtCookie, secret);
String kid = jwt.getClaim(Claims.kid).toString(); String kid = jwt.getClaim(Claims.kid).toString();