feat: add club member's gestion page
This commit is contained in:
@@ -2,13 +2,16 @@ package fr.titionfire.ffsaf.rest;
|
||||
|
||||
import fr.titionfire.ffsaf.domain.service.KeycloakService;
|
||||
import fr.titionfire.ffsaf.rest.from.MemberPermForm;
|
||||
import fr.titionfire.ffsaf.utils.GroupeUtils;
|
||||
import fr.titionfire.ffsaf.utils.Pair;
|
||||
import io.quarkus.oidc.IdToken;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import io.vertx.mutiny.core.Vertx;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.*;
|
||||
import org.eclipse.microprofile.jwt.JsonWebToken;
|
||||
import org.keycloak.representations.idm.GroupRepresentation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -19,11 +22,26 @@ public class CompteEndpoints {
|
||||
@Inject
|
||||
KeycloakService service;
|
||||
|
||||
@Inject
|
||||
JsonWebToken accessToken;
|
||||
|
||||
@Inject
|
||||
@IdToken
|
||||
JsonWebToken idToken;
|
||||
|
||||
@Inject
|
||||
Vertx vertx;
|
||||
|
||||
@GET
|
||||
@Path("{id}")
|
||||
@RolesAllowed("federation_admin")
|
||||
public Uni<?> getCompte(@PathParam("id") String id) {
|
||||
return service.fetchCompte(id);
|
||||
@RolesAllowed({"federation_admin", "club_president", "club_secretaire", "club_respo_intra"})
|
||||
public Uni<KeycloakService.UserCompteState> getCompte(@PathParam("id") String id) {
|
||||
return service.fetchCompte(id).call(pair -> vertx.getOrCreateContext().executeBlocking(() -> {
|
||||
if (!idToken.getGroups().contains("federation_admin") && !pair.getKey().groups().stream().map(GroupRepresentation::getPath)
|
||||
.anyMatch(s -> s.startsWith("/club/") && GroupeUtils.contains(s, accessToken)))
|
||||
throw new ForbiddenException();
|
||||
return pair;
|
||||
})).map(Pair::getValue);
|
||||
}
|
||||
|
||||
@PUT
|
||||
|
||||
Reference in New Issue
Block a user