Feature: Implement secure public pre-registration flow with CAPTCHA and HTMX dashboard
AS Talange CI/CD Pipeline / Build & Run Unit Tests (push) Successful in 3m12s
AS Talange CI/CD Pipeline / Build & Run in Docker Container (push) Successful in 3m4s

- Created V16 Flyway migration for pre_inscription and token_pre_inscription tables.
- Added PreInscription and TokenPreInscription entities with respective repositories.
- Updated SecurityConfig to allow public access to /inscription-public/**.
- Implemented CaptchaValidationService to interact with Cloudflare Turnstile API.
- Created PublicInscriptionController for managing the QR code entry, CAPTCHA validation, ephemeral tokens, and public form submission.
- Added public Thymeleaf views (demarrer, formulaire, succes, lien-expire) with TailwindCSS.
- Developed AdminPreInscriptionController and PreInscriptionService to handle back-office validation and rejection workflows.
- Built the admin pre-inscriptions dashboard list view.
- Added a dynamic, polling notification badge in the sidebar using HTMX, auto-updating on validation/rejection events.
This commit is contained in:
2026-06-11 23:11:34 +02:00
parent bca84be16a
commit 2e8298b3b6
16 changed files with 669 additions and 1 deletions
@@ -0,0 +1,79 @@
package com.astalange.core.entity;
import jakarta.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Entity
@Table(name = "pre_inscription")
public class PreInscription {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false, length = 100)
private String nom;
@Column(nullable = false, length = 100)
private String prenom;
@Column(name = "date_naissance", nullable = false)
private LocalDate dateNaissance;
@Column(length = 20)
private String telephone;
@Column(length = 150)
private String email;
@Column(columnDefinition = "TEXT")
private String adresse;
@Column(name = "representant_legal", length = 150)
private String representantLegal;
@Column(name = "statut_traite", nullable = false)
private Boolean statutTraite = false;
@Column(name = "date_creation", nullable = false)
private LocalDateTime dateCreation = LocalDateTime.now();
@ManyToOne(optional = false, fetch = FetchType.LAZY)
@JoinColumn(name = "saison_id", nullable = false)
private Saison saison;
// Getters and Setters
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
public String getNom() { return nom; }
public void setNom(String nom) { this.nom = nom; }
public String getPrenom() { return prenom; }
public void setPrenom(String prenom) { this.prenom = prenom; }
public LocalDate getDateNaissance() { return dateNaissance; }
public void setDateNaissance(LocalDate dateNaissance) { this.dateNaissance = dateNaissance; }
public String getTelephone() { return telephone; }
public void setTelephone(String telephone) { this.telephone = telephone; }
public String getEmail() { return email; }
public void setEmail(String email) { this.email = email; }
public String getAdresse() { return adresse; }
public void setAdresse(String adresse) { this.adresse = adresse; }
public String getRepresentantLegal() { return representantLegal; }
public void setRepresentantLegal(String representantLegal) { this.representantLegal = representantLegal; }
public Boolean getStatutTraite() { return statutTraite; }
public void setStatutTraite(Boolean statutTraite) { this.statutTraite = statutTraite; }
public LocalDateTime getDateCreation() { return dateCreation; }
public void setDateCreation(LocalDateTime dateCreation) { this.dateCreation = dateCreation; }
public Saison getSaison() { return saison; }
public void setSaison(Saison saison) { this.saison = saison; }
}
@@ -0,0 +1,40 @@
package com.astalange.core.entity;
import jakarta.persistence.*;
import java.time.LocalDateTime;
@Entity
@Table(name = "token_pre_inscription")
public class TokenPreInscription {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "valeur_uuid", nullable = false, unique = true, length = 36)
private String valeurUuid;
@Column(name = "date_expiration", nullable = false)
private LocalDateTime dateExpiration;
@Column(name = "est_utilise", nullable = false)
private Boolean estUtilise = false;
// Getters and Setters
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
public String getValeurUuid() { return valeurUuid; }
public void setValeurUuid(String valeurUuid) { this.valeurUuid = valeurUuid; }
public LocalDateTime getDateExpiration() { return dateExpiration; }
public void setDateExpiration(LocalDateTime dateExpiration) { this.dateExpiration = dateExpiration; }
public Boolean getEstUtilise() { return estUtilise; }
public void setEstUtilise(Boolean estUtilise) { this.estUtilise = estUtilise; }
@Transient
public boolean isValide() {
return !estUtilise && dateExpiration.isAfter(LocalDateTime.now());
}
}
@@ -0,0 +1,13 @@
package com.astalange.core.repository;
import com.astalange.core.entity.PreInscription;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface PreInscriptionRepository extends JpaRepository<PreInscription, Long> {
List<PreInscription> findByStatutTraiteFalseOrderByDateCreationDesc();
long countByStatutTraiteFalse();
}
@@ -0,0 +1,12 @@
package com.astalange.core.repository;
import com.astalange.core.entity.TokenPreInscription;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
@Repository
public interface TokenPreInscriptionRepository extends JpaRepository<TokenPreInscription, Long> {
Optional<TokenPreInscription> findByValeurUuid(String valeurUuid);
}
@@ -0,0 +1,50 @@
package com.astalange.core.service;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.Map;
@Service
public class CaptchaValidationService {
@Value("${captcha.secret:dummy-secret}")
private String captchaSecret;
@Value("${captcha.url:https://challenges.cloudflare.com/turnstile/v0/siteverify}")
private String captchaUrl;
public boolean validateCaptcha(String token) {
if (token == null || token.isEmpty()) {
return false;
}
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
map.add("secret", captchaSecret);
map.add("response", token);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(map, headers);
try {
ResponseEntity<Map> response = restTemplate.postForEntity(captchaUrl, request, Map.class);
if (response.getBody() != null && Boolean.TRUE.equals(response.getBody().get("success"))) {
return true;
}
} catch (Exception e) {
// Log error
return false;
}
return false;
}
}
@@ -0,0 +1,66 @@
package com.astalange.core.service;
import com.astalange.core.entity.Adherent;
import com.astalange.core.entity.Licence;
import com.astalange.core.entity.PreInscription;
import com.astalange.core.repository.AdherentRepository;
import com.astalange.core.repository.LicenceRepository;
import com.astalange.core.repository.PreInscriptionRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class PreInscriptionService {
private final PreInscriptionRepository preInscriptionRepository;
private final AdherentRepository adherentRepository;
private final LicenceRepository licenceRepository;
public PreInscriptionService(PreInscriptionRepository preInscriptionRepository,
AdherentRepository adherentRepository,
LicenceRepository licenceRepository) {
this.preInscriptionRepository = preInscriptionRepository;
this.adherentRepository = adherentRepository;
this.licenceRepository = licenceRepository;
}
@Transactional
public Adherent validerPreInscription(Long preInscriptionId, Long categorieId) {
PreInscription pre = preInscriptionRepository.findById(preInscriptionId)
.orElseThrow(() -> new IllegalArgumentException("Pré-inscription introuvable"));
if (pre.getStatutTraite()) {
throw new IllegalStateException("Cette pré-inscription a déjà été traitée");
}
// Créer l'adhérent
Adherent adherent = new Adherent();
adherent.setNom(pre.getNom().toUpperCase());
adherent.setPrenom(pre.getPrenom());
adherent.setDateNaissance(pre.getDateNaissance());
adherent.setTelephone(pre.getTelephone());
adherent.setEmail(pre.getEmail());
adherent.setAdresse(pre.getAdresse());
adherent.setRepresentantLegal(pre.getRepresentantLegal());
// Par défaut
adherent.setSexe("MASCULIN");
adherent.setTypeMaillot("JOUEUR");
adherent.setResidentTalange(false);
adherent = adherentRepository.save(adherent);
pre.setStatutTraite(true);
preInscriptionRepository.save(pre);
return adherent;
}
@Transactional
public void rejeterPreInscription(Long preInscriptionId) {
PreInscription pre = preInscriptionRepository.findById(preInscriptionId)
.orElseThrow(() -> new IllegalArgumentException("Pré-inscription introuvable"));
pre.setStatutTraite(true);
preInscriptionRepository.save(pre);
}
}
@@ -0,0 +1,21 @@
CREATE TABLE token_pre_inscription (
id BIGSERIAL PRIMARY KEY,
valeur_uuid VARCHAR(36) NOT NULL UNIQUE,
date_expiration TIMESTAMP NOT NULL,
est_utilise BOOLEAN NOT NULL DEFAULT FALSE
);
CREATE TABLE pre_inscription (
id BIGSERIAL PRIMARY KEY,
nom VARCHAR(100) NOT NULL,
prenom VARCHAR(100) NOT NULL,
date_naissance DATE NOT NULL,
telephone VARCHAR(20),
email VARCHAR(150),
adresse TEXT,
representant_legal VARCHAR(150),
statut_traite BOOLEAN NOT NULL DEFAULT FALSE,
date_creation TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
saison_id BIGINT NOT NULL,
CONSTRAINT fk_pre_inscription_saison FOREIGN KEY (saison_id) REFERENCES saison (id)
);
@@ -25,7 +25,7 @@ public class SecurityConfig {
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests(auth -> auth
.requestMatchers("/css/**", "/js/**", "/images/**").permitAll()
.requestMatchers("/css/**", "/js/**", "/images/**", "/inscription-public/**").permitAll()
.requestMatchers("/change-password").authenticated()
.requestMatchers("/utilisateurs/**", "/saisons/**", "/categories/**", "/equipes/**", "/modespaiement/**", "/equipements/**").hasRole("ADMIN")
.requestMatchers("/paiements/**", "/paiement/**").hasAnyRole("ADMIN", "TRESORERIE")
@@ -0,0 +1,55 @@
package com.astalange.web.controller;
import com.astalange.core.entity.Adherent;
import com.astalange.core.repository.PreInscriptionRepository;
import com.astalange.core.service.PreInscriptionService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
@Controller
@RequestMapping("/admin/pre-inscriptions")
public class AdminPreInscriptionController {
private final PreInscriptionRepository preInscriptionRepository;
private final PreInscriptionService preInscriptionService;
public AdminPreInscriptionController(PreInscriptionRepository preInscriptionRepository,
PreInscriptionService preInscriptionService) {
this.preInscriptionRepository = preInscriptionRepository;
this.preInscriptionService = preInscriptionService;
}
@GetMapping
public String listPreInscriptions(Model model) {
model.addAttribute("preInscriptions", preInscriptionRepository.findByStatutTraiteFalseOrderByDateCreationDesc());
return "preinscriptions/list";
}
@PostMapping("/{id}/valider")
public String valider(@PathVariable Long id, HttpServletResponse response) {
Adherent adherent = preInscriptionService.validerPreInscription(id, null);
response.setHeader("HX-Trigger", "refreshBadge");
// En HTMX, on renvoie une ligne vide pour la faire disparaître, ou on redirige via HX-Redirect
// Mais comme on veut aller sur la page de l'adhérent pour finaliser la licence :
response.setHeader("HX-Redirect", "/adherents/" + adherent.getId() + "/edit");
return "";
}
@PostMapping("/{id}/rejeter")
@ResponseBody
public String rejeter(@PathVariable Long id, HttpServletResponse response) {
preInscriptionService.rejeterPreInscription(id);
response.setHeader("HX-Trigger", "refreshBadge");
return ""; // HTMX target la ligne avec outerHTML -> supprime la ligne
}
@GetMapping("/count")
@ResponseBody
public String countBadge() {
long count = preInscriptionRepository.countByStatutTraiteFalse();
if (count == 0) return "";
return "<span class=\"bg-red-500 text-white rounded-full px-2 py-0.5 text-xs font-bold ml-2\">" + count + "</span>";
}
}
@@ -0,0 +1,101 @@
package com.astalange.web.controller;
import com.astalange.core.entity.PreInscription;
import com.astalange.core.entity.TokenPreInscription;
import com.astalange.core.entity.Saison;
import com.astalange.core.repository.PreInscriptionRepository;
import com.astalange.core.repository.TokenPreInscriptionRepository;
import com.astalange.core.repository.SaisonRepository;
import com.astalange.core.service.CaptchaValidationService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.time.LocalDateTime;
import java.util.UUID;
@Controller
@RequestMapping("/inscription-public")
public class PublicInscriptionController {
private final CaptchaValidationService captchaValidationService;
private final TokenPreInscriptionRepository tokenRepository;
private final PreInscriptionRepository preInscriptionRepository;
private final SaisonRepository saisonRepository;
public PublicInscriptionController(CaptchaValidationService captchaValidationService,
TokenPreInscriptionRepository tokenRepository,
PreInscriptionRepository preInscriptionRepository,
SaisonRepository saisonRepository) {
this.captchaValidationService = captchaValidationService;
this.tokenRepository = tokenRepository;
this.preInscriptionRepository = preInscriptionRepository;
this.saisonRepository = saisonRepository;
}
@GetMapping("/demarrer")
public String showDemarrer() {
return "public/demarrer";
}
@PostMapping("/demarrer")
public String processDemarrer(@RequestParam("cf-turnstile-response") String captchaResponse, RedirectAttributes redirectAttributes) {
// En vrai, captchaResponse dépend du fournisseur. Cloudflare Turnstile = cf-turnstile-response
if (!captchaValidationService.validateCaptcha(captchaResponse)) {
redirectAttributes.addFlashAttribute("error", "Validation CAPTCHA échouée. Veuillez réessayer.");
return "redirect:/inscription-public/demarrer";
}
TokenPreInscription token = new TokenPreInscription();
token.setValeurUuid(UUID.randomUUID().toString());
token.setDateExpiration(LocalDateTime.now().plusMinutes(10));
tokenRepository.save(token);
return "redirect:/inscription-public/formulaire?token=" + token.getValeurUuid();
}
@GetMapping("/formulaire")
public String showFormulaire(@RequestParam("token") String tokenUuid, Model model) {
TokenPreInscription token = tokenRepository.findByValeurUuid(tokenUuid).orElse(null);
if (token == null || !token.isValide()) {
return "public/lien-expire";
}
model.addAttribute("preInscription", new PreInscription());
model.addAttribute("tokenUuid", tokenUuid);
return "public/formulaire";
}
@PostMapping("/formulaire")
public String processFormulaire(@RequestParam("token") String tokenUuid,
@ModelAttribute("preInscription") PreInscription preInscription,
RedirectAttributes redirectAttributes) {
TokenPreInscription token = tokenRepository.findByValeurUuid(tokenUuid).orElse(null);
if (token == null || !token.isValide()) {
return "public/lien-expire";
}
Saison activeSaison = saisonRepository.findByEstActiveTrue().orElse(null);
if (activeSaison == null) {
redirectAttributes.addFlashAttribute("error", "Les inscriptions sont actuellement fermées.");
return "redirect:/inscription-public/demarrer";
}
// Sauvegarde de la pré-inscription
preInscription.setSaison(activeSaison);
preInscription.setStatutTraite(false);
preInscriptionRepository.save(preInscription);
// Invalidation du token
token.setEstUtilise(true);
tokenRepository.save(token);
return "redirect:/inscription-public/succes";
}
@GetMapping("/succes")
public String showSucces() {
return "public/succes";
}
}
@@ -12,6 +12,10 @@
<a href="/" th:classappend="${requestURI == '/' ? 'bg-blue-50 text-blue-700 font-medium' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'}" class="block px-3 py-2 rounded-lg transition-colors">Tableau de bord</a>
<a href="/adherents" th:classappend="${requestURI != null and requestURI.startsWith('/adherents') ? 'bg-blue-50 text-blue-700 font-medium' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'}" class="block px-3 py-2 rounded-lg transition-colors">Adhérents</a>
<a sec:authorize="hasAnyRole('ROLE_ADMIN', 'ROLE_AGENT_SAISIE')" href="/admin/pre-inscriptions" th:classappend="${requestURI != null and requestURI.startsWith('/admin/pre-inscriptions') ? 'bg-blue-50 text-blue-700 font-medium' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'}" class="flex items-center px-3 py-2 rounded-lg transition-colors">
<span>Pré-inscriptions</span>
<span hx-get="/admin/pre-inscriptions/count" hx-trigger="every 30s, refreshBadge from:body" hx-swap="outerHTML"></span>
</a>
<a sec:authorize="hasAnyRole('ROLE_ADMIN', 'ROLE_TRESORERIE')" href="/paiements" th:classappend="${requestURI != null and requestURI.startsWith('/paiements') ? 'bg-blue-50 text-blue-700 font-medium' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'}" class="block px-3 py-2 rounded-lg transition-colors">Paiements</a>
<th:block sec:authorize="hasAnyRole('ROLE_ADMIN', 'ROLE_AGENT_SAISIE')">
@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Pré-inscriptions - AS Talange</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/htmx.org@1.9.11"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<style> body { font-family: 'Inter', sans-serif; } </style>
</head>
<body class="bg-gray-50 text-gray-900 flex h-screen overflow-hidden">
<!-- Sidebar -->
<div th:replace="~{fragments/sidebar :: sidebar}"></div>
<main class="flex-1 flex flex-col h-screen overflow-hidden">
<header class="h-16 bg-white border-b border-gray-200 flex items-center px-6">
<h2 class="text-lg font-semibold text-gray-800">Dossiers en attente</h2>
</header>
<div class="flex-1 overflow-auto p-6">
<div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
<table class="w-full text-left border-collapse">
<thead>
<tr class="bg-gray-50 text-gray-500 text-sm uppercase tracking-wider border-b border-gray-200">
<th class="py-3 px-6 font-medium">Date</th>
<th class="py-3 px-6 font-medium">Adhérent</th>
<th class="py-3 px-6 font-medium">Contact</th>
<th class="py-3 px-6 font-medium text-right">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200 text-sm">
<tr th:if="${#lists.isEmpty(preInscriptions)}">
<td colspan="4" class="py-8 text-center text-gray-500">Aucune pré-inscription en attente.</td>
</tr>
<tr th:each="pre : ${preInscriptions}" th:id="'pre-' + ${pre.id}" class="hover:bg-gray-50 transition-colors">
<td class="py-4 px-6 text-gray-600" th:text="${#temporals.format(pre.dateCreation, 'dd/MM/yyyy HH:mm')}"></td>
<td class="py-4 px-6">
<div class="font-medium text-gray-900" th:text="${pre.nom + ' ' + pre.prenom}"></div>
<div class="text-xs text-gray-500" th:text="'Né(e) le ' + ${#temporals.format(pre.dateNaissance, 'dd/MM/yyyy')}"></div>
<div th:if="${pre.representantLegal != null}" class="text-[10px] text-blue-600 font-semibold mt-1" th:text="'Parent : ' + ${pre.representantLegal}"></div>
</td>
<td class="py-4 px-6">
<div class="text-gray-900" th:text="${pre.telephone}"></div>
<div class="text-xs text-gray-500" th:text="${pre.email}"></div>
</td>
<td class="py-4 px-6 text-right space-x-2">
<button th:hx-post="@{/admin/pre-inscriptions/{id}/valider(id=${pre.id})}"
class="bg-blue-600 text-white px-3 py-1.5 rounded hover:bg-blue-700 transition-colors">
Créer la fiche
</button>
<button th:hx-post="@{/admin/pre-inscriptions/{id}/rejeter(id=${pre.id})}"
th:hx-target="'#pre-' + ${pre.id}"
hx-swap="outerHTML"
hx-confirm="Confirmer le rejet du dossier ?"
class="bg-red-50 text-red-600 border border-red-200 px-3 py-1.5 rounded hover:bg-red-100 transition-colors">
Rejeter
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</main>
</body>
</html>
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>AS Talange - Pré-inscription</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
<style> body { font-family: 'Inter', sans-serif; } </style>
</head>
<body class="bg-gray-50 flex items-center justify-center min-h-screen">
<div class="max-w-md w-full bg-white rounded-xl shadow-md p-8 border border-gray-100 text-center">
<img src="/images/logo.png" alt="AS Talange" class="h-24 mx-auto mb-6 opacity-80" onerror="this.style.display='none'">
<h1 class="text-2xl font-bold text-gray-900 mb-2">Inscription au club</h1>
<p class="text-gray-600 mb-8">Veuillez valider le captcha pour accéder au formulaire sécurisé.</p>
<div th:if="${error}" class="bg-red-50 text-red-600 p-3 rounded-lg mb-6 text-sm" th:text="${error}"></div>
<div th:if="${param.error}" class="bg-red-50 text-red-600 p-3 rounded-lg mb-6 text-sm">Les inscriptions sont actuellement fermées.</div>
<form th:action="@{/inscription-public/demarrer}" method="post" class="flex flex-col items-center">
<!-- Remplacer par la vraie clé de site Cloudflare Turnstile -->
<div class="cf-turnstile mb-6" data-sitekey="1x00000000000000000000AA"></div>
<button type="submit" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-4 rounded-lg transition-colors">
Accéder au formulaire
</button>
</form>
</div>
</body>
</html>
@@ -0,0 +1,85 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>AS Talange - Formulaire d'inscription</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<style> body { font-family: 'Inter', sans-serif; } </style>
</head>
<body class="bg-gray-50 flex items-center justify-center min-h-screen py-12">
<div class="max-w-xl w-full bg-white rounded-xl shadow-md p-8 border border-gray-100">
<h2 class="text-2xl font-bold text-gray-900 mb-6 text-center">Formulaire de pré-inscription</h2>
<p class="text-sm text-gray-500 mb-8 text-center">Veuillez remplir les informations concernant le futur licencié.</p>
<form th:action="@{/inscription-public/formulaire}" th:object="${preInscription}" method="post" class="space-y-6">
<input type="hidden" name="token" th:value="${tokenUuid}" />
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Nom <span class="text-red-500">*</span></label>
<input type="text" th:field="*{nom}" required class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none uppercase">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Prénom <span class="text-red-500">*</span></label>
<input type="text" th:field="*{prenom}" required class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none capitalize">
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Date de naissance <span class="text-red-500">*</span></label>
<input type="date" id="dateNaissance" th:field="*{dateNaissance}" required class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none">
</div>
<div id="representantBlock" class="hidden bg-blue-50 p-4 rounded-lg border border-blue-100">
<label class="block text-sm font-medium text-blue-800 mb-1">Représentant légal <span class="text-red-500">*</span></label>
<p class="text-xs text-blue-600 mb-2">Obligatoire pour les mineurs.</p>
<input type="text" id="representantLegal" th:field="*{representantLegal}" placeholder="Nom et Prénom du parent" class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none">
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Téléphone</label>
<input type="tel" th:field="*{telephone}" class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Email</label>
<input type="email" th:field="*{email}" class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none">
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Adresse postale</label>
<textarea th:field="*{adresse}" rows="3" class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none"></textarea>
</div>
<button type="submit" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-4 rounded-lg transition-colors mt-4">
Soumettre le dossier
</button>
</form>
</div>
<script>
document.getElementById('dateNaissance').addEventListener('change', function() {
const dateInput = this.value;
const repBlock = document.getElementById('representantBlock');
const repInput = document.getElementById('representantLegal');
if (dateInput) {
const dob = new Date(dateInput);
const ageDifMs = Date.now() - dob.getTime();
const ageDate = new Date(ageDifMs);
const age = Math.abs(ageDate.getUTCFullYear() - 1970);
if (age < 18) {
repBlock.classList.remove('hidden');
repInput.required = true;
} else {
repBlock.classList.add('hidden');
repInput.required = false;
}
}
});
</script>
</body>
</html>
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Lien expiré</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<style> body { font-family: 'Inter', sans-serif; } </style>
</head>
<body class="bg-gray-50 flex items-center justify-center min-h-screen">
<div class="max-w-md w-full bg-white rounded-xl shadow-md p-8 border border-gray-100 text-center">
<div class="w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mx-auto mb-4">
<svg class="w-8 h-8 text-red-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
</svg>
</div>
<h1 class="text-2xl font-bold text-gray-900 mb-2">Lien invalide ou expiré</h1>
<p class="text-gray-600 mb-8">Votre session a expiré ou le lien utilisé est invalide. Veuillez recommencer la procédure depuis le début.</p>
<a th:href="@{/inscription-public/demarrer}" class="w-full inline-block bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-4 rounded-lg transition-colors">
Recommencer
</a>
</div>
</body>
</html>
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Inscription réussie</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<style> body { font-family: 'Inter', sans-serif; } </style>
</head>
<body class="bg-gray-50 flex items-center justify-center min-h-screen">
<div class="max-w-md w-full bg-white rounded-xl shadow-md p-8 border border-gray-100 text-center">
<div class="w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4">
<svg class="w-8 h-8 text-green-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
</svg>
</div>
<h1 class="text-2xl font-bold text-gray-900 mb-2">Pré-inscription envoyée !</h1>
<p class="text-gray-600 mb-2">Votre dossier a bien été transmis au secrétariat de l'AS Talange.</p>
<p class="text-sm text-gray-500">Un responsable va traiter votre demande prochainement. Vous pouvez fermer cette page.</p>
</div>
</body>
</html>