55 lines
1.0 KiB
Go
55 lines
1.0 KiB
Go
package props
|
|
|
|
import (
|
|
"lishwist/http/props/htmlx"
|
|
)
|
|
|
|
type Login struct {
|
|
GeneralError string `json:",omitempty" xml:",omitempty"`
|
|
SuccessfulRegistration bool `json:",omitempty" xml:",omitempty"`
|
|
SuccessfulSetPassword bool `json:",omitempty" xml:",omitempty"`
|
|
Username htmlx.Input
|
|
Password htmlx.Input
|
|
RegisterLink htmlx.Link
|
|
Submit htmlx.Submit
|
|
}
|
|
|
|
func NewLogin(username, password string) *Login {
|
|
return &Login{
|
|
Username: htmlx.Input{
|
|
Label: "Username",
|
|
Name: "username",
|
|
Required: true,
|
|
Value: username,
|
|
},
|
|
Password: htmlx.Input{
|
|
Label: "Password",
|
|
Name: "password",
|
|
Type: "password",
|
|
Required: true,
|
|
Value: password,
|
|
},
|
|
RegisterLink: htmlx.Link{
|
|
Name: "Register",
|
|
Href: "/register",
|
|
},
|
|
Submit: htmlx.Submit{
|
|
Label: "Login",
|
|
},
|
|
}
|
|
}
|
|
|
|
func (p *Login) Validate() (valid bool) {
|
|
valid = true
|
|
|
|
if !p.Username.Validate() {
|
|
valid = false
|
|
}
|
|
|
|
if !p.Password.Validate() {
|
|
valid = false
|
|
}
|
|
|
|
return
|
|
}
|