fix: resolve HTMX POST CSRF token and unhandled ViewResolver 500 error
This commit is contained in:
+1
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE saison ADD COLUMN inscriptions_ouvertes BOOLEAN NOT NULL DEFAULT FALSE;
|
||||||
+1
@@ -28,6 +28,7 @@ public class AdminPreInscriptionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/{id}/valider")
|
@PostMapping("/{id}/valider")
|
||||||
|
@ResponseBody
|
||||||
public String valider(@PathVariable Long id, HttpServletResponse response) {
|
public String valider(@PathVariable Long id, HttpServletResponse response) {
|
||||||
Adherent adherent = preInscriptionService.validerPreInscription(id, null);
|
Adherent adherent = preInscriptionService.validerPreInscription(id, null);
|
||||||
response.setHeader("HX-Trigger", "refreshBadge");
|
response.setHeader("HX-Trigger", "refreshBadge");
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
<script src="https://unpkg.com/htmx.org@1.9.11"></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">
|
<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>
|
<style> body { font-family: 'Inter', sans-serif; } </style>
|
||||||
|
<meta name="_csrf" th:content="${_csrf.token}"/>
|
||||||
|
<meta name="_csrf_header" th:content="${_csrf.headerName}"/>
|
||||||
</head>
|
</head>
|
||||||
<body class="bg-gray-50 text-gray-900 flex h-screen overflow-hidden">
|
<body class="bg-gray-50 text-gray-900 flex h-screen overflow-hidden">
|
||||||
<!-- Sidebar -->
|
<!-- Sidebar -->
|
||||||
@@ -44,12 +46,11 @@
|
|||||||
<div class="text-xs text-gray-500" th:text="${pre.email}"></div>
|
<div class="text-xs text-gray-500" th:text="${pre.email}"></div>
|
||||||
</td>
|
</td>
|
||||||
<td class="py-4 px-6 text-right space-x-2">
|
<td class="py-4 px-6 text-right space-x-2">
|
||||||
<button th:hx-post="@{/admin/pre-inscriptions/{id}/valider(id=${pre.id})}"
|
<button th:attr="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">
|
class="bg-blue-600 text-white px-3 py-1.5 rounded hover:bg-blue-700 transition-colors">
|
||||||
Créer la fiche
|
Créer la fiche
|
||||||
</button>
|
</button>
|
||||||
<button th:hx-post="@{/admin/pre-inscriptions/{id}/rejeter(id=${pre.id})}"
|
<button th:attr="hx-post=@{/admin/pre-inscriptions/{id}/rejeter(id=${pre.id})}, hx-target=|#pre-${pre.id}|"
|
||||||
th:hx-target="'#pre-' + ${pre.id}"
|
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
hx-confirm="Confirmer le rejet du dossier ?"
|
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">
|
class="bg-red-50 text-red-600 border border-red-200 px-3 py-1.5 rounded hover:bg-red-100 transition-colors">
|
||||||
@@ -62,5 +63,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
document.body.addEventListener('htmx:configRequest', function(evt) {
|
||||||
|
evt.detail.headers[document.querySelector('meta[name="_csrf_header"]').content] =
|
||||||
|
document.querySelector('meta[name="_csrf"]').content;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user