fix(web): inject CSRF meta on custom login pages

Site-owned GET /login no longer serves the framework form; stamp
csrf-token + session cookie on page render so JS can still POST /login.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-09-18 10:49:56 +08:00
1 parent fb30cd3db3
commit bfea2204eb
3 files changed
+46 -3

No files matched your search

+3
View File
@@ -731,6 +731,9 @@ func headHTML(page map[string]any, defaultTitle string) string {
}
var s strings.Builder
s.WriteString(fmt.Sprintf("<title>%s</title>", esc(pageTitle)))
if csrf, ok := page["_csrf"].(string); ok && strings.TrimSpace(csrf) != "" {
s.WriteString(fmt.Sprintf(`<meta name="csrf-token" content="%s"/>`, esc(strings.TrimSpace(csrf))))
}
if meta, ok := page["meta"].(map[string]any); ok {
for k, v := range meta {
if k == "title" {