internal/httpd/confirm.go

e2dec5d9ff2cd5dd54f68adec4190d8bafeaf302
gitbay/internal/httpd/confirm.go history · blame · raw

17 lines · 463 bytes

 1package httpd
 2
 3import (
 4	"net/http"
 5	"strings"
 6)
 7
 8// confirmed reports whether the form typed want into its confirm field.
 9// It guards controls that destroy data nothing else holds; the person
10// is already authorised, so this is a check against a slip, not a
11// permission.
12func confirmed(r *http.Request, want string) (bool, string) {
13	if strings.TrimSpace(r.FormValue("confirm")) == want {
14		return true, ""
15	}
16	return false, "type " + want + " to confirm"
17}