Compare commits
2 Commits
1caf06934f
...
e6bf0da7c6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6bf0da7c6 | ||
|
|
c069ad02ce |
@ -3,13 +3,13 @@ module lishwist/http
|
|||||||
go 1.25.5
|
go 1.25.5
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Teajey/rsvp v0.19.0-rc.2
|
github.com/Teajey/rsvp v0.21.1
|
||||||
github.com/gorilla/sessions v1.4.0
|
github.com/gorilla/sessions v1.4.0
|
||||||
golang.org/x/crypto v0.39.0
|
golang.org/x/crypto v0.39.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Teajey/hmc v0.6.0-rc.12
|
github.com/Teajey/hmc v0.9.0
|
||||||
github.com/gorilla/securecookie v1.1.2
|
github.com/gorilla/securecookie v1.1.2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,11 @@
|
|||||||
github.com/Teajey/hmc v0.6.0-rc.12 h1:Vkx6mJa3pfMlYx4vyI9LfVLHa8fNyl8LikMvXBfDGZk=
|
github.com/Teajey/hmc v0.6.0-rc.12 h1:Vkx6mJa3pfMlYx4vyI9LfVLHa8fNyl8LikMvXBfDGZk=
|
||||||
github.com/Teajey/hmc v0.6.0-rc.12/go.mod h1:9K7SL4RyybNLHooqsZcyFoL6QGqqa2zPgIBidw4qWQY=
|
github.com/Teajey/hmc v0.6.0-rc.12/go.mod h1:9K7SL4RyybNLHooqsZcyFoL6QGqqa2zPgIBidw4qWQY=
|
||||||
|
github.com/Teajey/hmc v0.9.0 h1:OYDn95/ZheJlVQTXFIztsuU2jUG57XahcMpJZ5dM1VQ=
|
||||||
|
github.com/Teajey/hmc v0.9.0/go.mod h1:9K7SL4RyybNLHooqsZcyFoL6QGqqa2zPgIBidw4qWQY=
|
||||||
github.com/Teajey/rsvp v0.19.0-rc.2 h1:h4V7c3uGlSKajkWKt3fldFV+XTMEI8A4o05PMY8xv9A=
|
github.com/Teajey/rsvp v0.19.0-rc.2 h1:h4V7c3uGlSKajkWKt3fldFV+XTMEI8A4o05PMY8xv9A=
|
||||||
github.com/Teajey/rsvp v0.19.0-rc.2/go.mod h1:z0L20VphVg+Ec2+hnpLFTG2MZTrWYFprav1kpxDba0Q=
|
github.com/Teajey/rsvp v0.19.0-rc.2/go.mod h1:z0L20VphVg+Ec2+hnpLFTG2MZTrWYFprav1kpxDba0Q=
|
||||||
|
github.com/Teajey/rsvp v0.21.1 h1:qDo0VHvatOKFG6oqsq3daPOq0TU9pjicdz5mwxwGMO4=
|
||||||
|
github.com/Teajey/rsvp v0.21.1/go.mod h1:z0L20VphVg+Ec2+hnpLFTG2MZTrWYFprav1kpxDba0Q=
|
||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
||||||
|
|||||||
@ -85,9 +85,9 @@ func (m *Private) handleWithSession(pattern string, next handler.PublicFunc) {
|
|||||||
r: r,
|
r: r,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := rsvp.Write(rw, m.rsvp, r, func(w rsvp.ResponseWriter, r *http.Request) rsvp.Body {
|
err := rsvp.Write(rw, r, m.rsvp, rsvp.HandlerFunc(func(w rsvp.ResponseWriter, r *http.Request) rsvp.Body {
|
||||||
return next(s, w, r)
|
return next(s, w, r)
|
||||||
})
|
}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("rsvp failed to write a response: %s", err)
|
log.Printf("rsvp failed to write a response: %s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -178,19 +178,19 @@ func InitialTodo(todo []lishwist.Wish) Wishlist {
|
|||||||
|
|
||||||
func (w Wishlist) ExtractFormValues(form url.Values) {
|
func (w Wishlist) ExtractFormValues(form url.Values) {
|
||||||
if w.NewWish != nil {
|
if w.NewWish != nil {
|
||||||
w.NewWish.Elements.ExtractFormValue(form)
|
_ = w.NewWish.Elements.ExtractValue(form)
|
||||||
}
|
}
|
||||||
|
|
||||||
if w.Wishes == nil {
|
if w.Wishes == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := w.Wishes.Elements.Select.ExtractFormValue(form)
|
err := w.Wishes.Elements.Select.ExtractValue(form)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.Wishes.Elements.Select.Error = err.Error()
|
w.Wishes.Elements.Select.Error = err.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
err = w.Wishes.Elements.Intent.ExtractFormValue(form)
|
err = w.Wishes.Elements.Intent.ExtractValue(form)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.Wishes.Elements.Intent.Error = err.Error()
|
w.Wishes.Elements.Intent.Error = err.Error()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package routing
|
package routing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -103,10 +104,10 @@ func LoginPost(session *session.Session, w rsvp.ResponseWriter, r *http.Request)
|
|||||||
login := LoginMiddle(username, password, session, r)
|
login := LoginMiddle(username, password, session, r)
|
||||||
if login != nil {
|
if login != nil {
|
||||||
page.Form.Elements = *login
|
page.Form.Elements = *login
|
||||||
return rsvp.Data(page).StatusSeeOther("")
|
return rsvp.Data(page).StatusSeeOther(".")
|
||||||
}
|
}
|
||||||
|
|
||||||
referrer := r.URL.Query().Get("referrer")
|
referrer := r.URL.Query().Get("referrer")
|
||||||
|
|
||||||
return rsvp.Data("Login successful!").StatusSeeOther(referrer)
|
return rsvp.Data("Login successful!").StatusSeeOther(cmp.Or(referrer, "."))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{{define "input"}}
|
{{define "input"}}
|
||||||
<input style="padding: .375rem .75rem;" class="form-control{{if .Error}} is-invalid{{end}}" {{if .Type}}type="{{.Type}}" {{end}}name="{{.Name}}"
|
<input style="padding: .375rem .75rem;" class="form-control{{if .Error}} is-invalid{{end}}" {{if .Type}}type="{{.Type}}" {{end}}name="{{.Name}}"
|
||||||
value="{{.Value}}" {{if .Required}}required {{end}}{{if .MinLength}}minlength="{{.MinLength}}" {{end}}{{with .Error}} aria-describedby="{{.Name}}Error"{{end}}>
|
value="{{.Value}}" {{if .Required}}required {{end}}{{if .MinLength}}minlength="{{.MinLength}}" {{end}}{{with .Error}} aria-describedby="{{$.Name}}Error"{{end}}>
|
||||||
{{with .Error}}
|
{{with .Error}}
|
||||||
<div id="{{$.Name}}Error" class="invalid-feedback">
|
<div id="{{$.Name}}Error" class="invalid-feedback">
|
||||||
{{.}}
|
{{.}}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user