From 91534ed8bd621b5a55b1e8e114b77a526a89a41a Mon Sep 17 00:00:00 2001 From: cclohmar Date: Wed, 3 Jun 2026 07:57:56 +0000 Subject: [PATCH] fix: renderOTPForm in auth.go now uses cached single-field template - Was using its own inline template with 6 digit_0..digit_5 fields - Now calls getTemplate('otp_form') which has the single 6-digit input - templates.go already had the correct single-field version --- internal/handlers/auth.go | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/internal/handlers/auth.go b/internal/handlers/auth.go index 4e4b993..09c6151 100644 --- a/internal/handlers/auth.go +++ b/internal/handlers/auth.go @@ -257,35 +257,10 @@ func renderError(w http.ResponseWriter, message string) { fmt.Fprintf(w, `
%s
`, template.HTMLEscapeString(message)) } -// renderOTPForm writes the OTP verification form partial as an HTMX fragment. -// It renders 6 individual digit input boxes for a better mobile UX, plus a -// hidden email field. The handler combines the 6 digits server-side. -// If errMsg is non-empty, it is displayed as an error banner above the form. +// renderOTPForm writes the OTP verification form partial as an HTMX fragment +// using the cached otp_form template from templates.go. func renderOTPForm(w http.ResponseWriter, email string, errMsg string) { - tmpl := template.Must(template.New("otp_form").Parse(` -
- - {{if .Error}}
{{.Error}}
{{end}} -
- - - - - - -
- -
-`)) - + tmpl := getTemplate("otp_form") w.Header().Set("Content-Type", "text/html; charset=utf-8") if err := tmpl.Execute(w, map[string]string{"Email": email, "Error": errMsg}); err != nil { log.Printf("ERROR [%s] handlers: renderOTPForm execute: %v", time.Now().Format(time.RFC3339), err)