Register link goes outside login form
This commit is contained in:
parent
84fb52ac21
commit
60b4fa773c
@ -8,7 +8,6 @@ type Login struct {
|
|||||||
SuccessfulSetPassword bool `json:",omitempty" xml:",omitempty"`
|
SuccessfulSetPassword bool `json:",omitempty" xml:",omitempty"`
|
||||||
Username hmc.Input
|
Username hmc.Input
|
||||||
Password hmc.Input
|
Password hmc.Input
|
||||||
RegisterLink hmc.Link
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLogin(username, password string) Login {
|
func NewLogin(username, password string) Login {
|
||||||
@ -26,10 +25,6 @@ func NewLogin(username, password string) Login {
|
|||||||
Required: true,
|
Required: true,
|
||||||
Value: password,
|
Value: password,
|
||||||
},
|
},
|
||||||
RegisterLink: hmc.Link{
|
|
||||||
Label: "Register",
|
|
||||||
Href: "/register",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,21 @@ import (
|
|||||||
|
|
||||||
type LoginPage struct {
|
type LoginPage struct {
|
||||||
hmc.Namespace
|
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 {
|
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
|
login.SuccessfulSetPassword = flashProps.SuccessfulSetPassword
|
||||||
}
|
}
|
||||||
|
|
||||||
body := LoginPage{
|
body := NewLoginPage()
|
||||||
Namespace: hmc.NS(),
|
body.Form.Elements = login
|
||||||
Form: hmc.Form[props.Login]{Method: "POST", Elements: login},
|
|
||||||
}
|
|
||||||
return rsvp.Body{TemplateName: "login.gotmpl", Data: body}
|
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 {
|
func LoginPost(session *session.Session, w rsvp.ResponseWriter, r *http.Request) rsvp.Body {
|
||||||
page := LoginPage{
|
page := NewLoginPage()
|
||||||
Namespace: hmc.NS(),
|
|
||||||
Form: hmc.Form[props.Login]{Method: "POST"},
|
|
||||||
}
|
|
||||||
|
|
||||||
err := r.ParseForm()
|
err := r.ParseForm()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -35,7 +35,7 @@
|
|||||||
{{template "input" .Password}}
|
{{template "input" .Password}}
|
||||||
</label>
|
</label>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
{{template "hyperlink" .RegisterLink}}
|
{{template "hyperlink" $.RegisterLink}}
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-primary" type="submit">Login</button>
|
<button class="btn btn-primary" type="submit">Login</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user