Register link goes outside login form

This commit is contained in:
Teajey 2026-02-21 10:20:59 +09:00
parent 84fb52ac21
commit 60b4fa773c
Signed by: Teajey
GPG Key ID: 970E790FE834A713
3 changed files with 19 additions and 15 deletions

View File

@ -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",
},
}
}

View File

@ -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 {

View File

@ -35,7 +35,7 @@
{{template "input" .Password}}
</label>
<div class="mb-3">
{{template "hyperlink" .RegisterLink}}
{{template "hyperlink" $.RegisterLink}}
</div>
<button class="btn btn-primary" type="submit">Login</button>
</div>