feat: restrict license creation to only one license per adherent

This commit is contained in:
2026-05-19 22:53:05 +02:00
parent bcd4a94973
commit 2a116b1e02
2 changed files with 7 additions and 1 deletions
@@ -48,6 +48,12 @@ public class LicenceController {
Adherent adherent = adherentRepository.findById(id)
.orElseThrow(() -> new IllegalArgumentException("Invalid Adherent ID"));
List<Licence> existingLicences = licenceRepository.findByAdherentId(id);
if (!existingLicences.isEmpty()) {
return "redirect:/adherents/" + id + "/edit";
}
Categorie categorie = categorieRepository.findById(categorieId)
.orElseThrow(() -> new IllegalArgumentException("Invalid Categorie ID"));