From 53eb700afb88b9483d298479409902e02b7a2b11 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Tue, 26 Jul 2022 00:09:17 +0200 Subject: [PATCH] add function count for admin --- .../java/com/covas/Resources/UsersRessources.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/covas/Resources/UsersRessources.java b/src/main/java/com/covas/Resources/UsersRessources.java index 9392a36..5aec4d8 100644 --- a/src/main/java/com/covas/Resources/UsersRessources.java +++ b/src/main/java/com/covas/Resources/UsersRessources.java @@ -77,6 +77,20 @@ public class UsersRessources { return responseHttp; } + @GET + @RolesAllowed("Admin") + @Path("count") + public Response getCount(@CookieParam("user") String userCookie, @Context SecurityContext ctx){ + UUID kid = UUID.fromString(jwt.getClaim(Claims.kid)); + UsersEntity user = UsersEntity.findById(kid); + Response.Status status = getResponseCheck(ctx, userCookie, user); + Response responseHttp = Response.status(status).build(); + if (status.equals(Response.Status.OK)){ + responseHttp = Response.ok(UsersEntity.count()).build(); + } + return responseHttp; + } + @GET @RolesAllowed("Admin") @Path("{id}")