From 60b4fa773c55e537c28a4c9ae19c8e465867f046 Mon Sep 17 00:00:00 2001 From: Teajey <21069848+Teajey@users.noreply.github.com> Date: Sat, 21 Feb 2026 10:20:59 +0900 Subject: [PATCH] Register link goes outside login form --- http/props/login.go | 5 ----- http/routing/login.go | 27 ++++++++++++++++++--------- http/templates/login.gotmpl | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/http/props/login.go b/http/props/login.go index 5742139..9e0891d 100644 --- a/http/props/login.go +++ b/http/props/login.go @@ -8,7 +8,6 @@ type Login struct { SuccessfulSetPassword bool `json:",omitempty" xml:",omitempty"` Username hmc.Input Password hmc.Input - RegisterLink hmc.Link } func NewLogin(username, password string) Login { @@ -26,10 +25,6 @@ func NewLogin(username, password string) Login { Required: true, Value: password, }, - RegisterLink: hmc.Link{ - Label: "Register", - Href: "/register", - }, } } diff --git a/http/routing/login.go b/http/routing/login.go index edf80b6..55b0167 100644 --- a/http/routing/login.go +++ b/http/routing/login.go @@ -16,7 +16,21 @@ import ( type LoginPage struct { hmc.Namespace - Form hmc.Form[props.Login] + Form hmc.Form[props.Login] + RegisterLink hmc.Link +} + +func NewLoginPage() LoginPage { + return LoginPage{ + Namespace: hmc.NS(), + Form: hmc.Form[props.Login]{ + Method: "POST", + }, + RegisterLink: hmc.Link{ + Label: "Register", + Href: "/register", + }, + } } func Login(s *session.Session, w rsvp.ResponseWriter, r *http.Request) rsvp.Body { @@ -35,10 +49,8 @@ func Login(s *session.Session, w rsvp.ResponseWriter, r *http.Request) rsvp.Body login.SuccessfulSetPassword = flashProps.SuccessfulSetPassword } - body := LoginPage{ - Namespace: hmc.NS(), - Form: hmc.Form[props.Login]{Method: "POST", Elements: login}, - } + body := NewLoginPage() + body.Form.Elements = login return rsvp.Body{TemplateName: "login.gotmpl", Data: body} } @@ -77,10 +89,7 @@ func LoginMiddle(username, password string, session *session.Session, r *http.Re } func LoginPost(session *session.Session, w rsvp.ResponseWriter, r *http.Request) rsvp.Body { - page := LoginPage{ - Namespace: hmc.NS(), - Form: hmc.Form[props.Login]{Method: "POST"}, - } + page := NewLoginPage() err := r.ParseForm() if err != nil { diff --git a/http/templates/login.gotmpl b/http/templates/login.gotmpl index 2345c14..3db12a0 100644 --- a/http/templates/login.gotmpl +++ b/http/templates/login.gotmpl @@ -35,7 +35,7 @@ {{template "input" .Password}}