1package web
2
3import (
4 "net/http"
5
6 "tug/internal/transport/web/text"
7)
8
9func (k *Kit) endedSessionForm(again http.HandlerFunc) http.Handler {
10 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
11 r.Body = http.MaxBytesReader(w, r.Body, maxFormBytes)
12 if _, live := PrincipalFrom(r); live || r.PostFormValue(csrfField) == "" {
13 k.renderError(w, r, http.StatusForbidden, text.ErrorForbiddenTitle, text.ErrorFormExpired)
14 return
15 }
16 again(w, r)
17 })
18}