Fix csrf token for forms

This commit is contained in:
Marcus Kammer 2024-10-22 16:32:52 +02:00
parent 0c189610ca
commit ec1665bdcf

View file

@ -503,7 +503,7 @@ See also: extract-question-components, split-list-by-keyword, resolve-input-and-
`(progn ,@(loop for value in values
collect `(:li (apply-input-form ,type ,group ,value))))))))))))
(defmacro with-form ((&key action intro) &body body)
(defmacro with-form ((&key csrf-token action intro) &body body)
"Create a standardized HTML form wrapped in a <div> tag with a pre-defined
class and structure, using the Spinneret library.
@ -512,12 +512,12 @@ ACTION: Form action.
INTRO: Write some information related to the form. Could be a introduction."
`(spinneret:with-html
(:div
(when ,intro (:p :class "alert alert-light" ,intro))
,@(when intro `((:p :class "alert alert-light" ,intro)))
(:form :action (unless ,action "/")
:method "post"
:class (spacing :property "m" :side "y" :size 1)
(when csrf-token
(:input :type "hidden" :name "csrf-token" :value csrf-token))
,@(when csrf-token
`((:input :type "hidden" :name "csrf-token" :value ,csrf-token)))
,@body
(btn-primary (:type "submit")
(t9n "submit"))))))