custom: Add new footer template and context

This commit is contained in:
Tom Wiesing 2023-01-06 19:56:13 +01:00
parent 009d649ea6
commit bda763725e
No known key found for this signature in database
18 changed files with 197 additions and 33 deletions

View file

@ -111,6 +111,8 @@ var errLoginFailed = errors.New("Login failed")
// authLogin implements a view to login a user
func (auth *Auth) authLogin(ctx context.Context) http.Handler {
loginTemplate := auth.Dependencies.Custom.Template(loginTemplate)
return &httpx.Form[*AuthUser]{
Fields: []httpx.Field{
{Name: "username", Type: httpx.TextField, Label: "Username"},
@ -123,7 +125,7 @@ func (auth *Auth) authLogin(ctx context.Context) http.Handler {
if context.Err != nil {
context.Err = errLoginFailed
}
httpx.WriteHTML(context, nil, loginTemplate, "", w, r)
httpx.WriteHTML(auth.Dependencies.Custom.NewForm(context), nil, loginTemplate, "", w, r)
},
Validate: func(r *http.Request, values map[string]string) (*AuthUser, error) {