Fix ob: type not registered for interface: map[string]string & superfluous response.WriteHeader, as well as wired up to go to custom 500 messages.
This commit is contained in:
@@ -72,8 +72,8 @@ func SignupPost(c *gin.Context) {
|
|||||||
AcceptTerms: r.FormValue("accept_terms") == "on",
|
AcceptTerms: r.FormValue("accept_terms") == "on",
|
||||||
}
|
}
|
||||||
|
|
||||||
errors := validateRegisterForm(db, form)
|
errMap := validateRegisterForm(db, form)
|
||||||
if len(errors) > 0 {
|
if len(errMap) > 0 {
|
||||||
formMap := map[string]string{
|
formMap := map[string]string{
|
||||||
"username": form.Username,
|
"username": form.Username,
|
||||||
"email": form.Email,
|
"email": form.Email,
|
||||||
@@ -85,7 +85,7 @@ func SignupPost(c *gin.Context) {
|
|||||||
}(),
|
}(),
|
||||||
}
|
}
|
||||||
sm.Put(r.Context(), "register.form", formMap)
|
sm.Put(r.Context(), "register.form", formMap)
|
||||||
sm.Put(r.Context(), "register.errors", errors)
|
sm.Put(r.Context(), "register.errors", errMap)
|
||||||
sm.Put(r.Context(), "flash", "Please fix the highlighted errors.")
|
sm.Put(r.Context(), "flash", "Please fix the highlighted errors.")
|
||||||
|
|
||||||
c.Redirect(http.StatusSeeOther, "/account/signup")
|
c.Redirect(http.StatusSeeOther, "/account/signup")
|
||||||
@@ -153,6 +153,5 @@ func validateRegisterForm(db *sql.DB, f registerForm) map[string]string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func looksLikeEmail(s string) bool {
|
func looksLikeEmail(s string) bool {
|
||||||
|
|
||||||
return strings.Count(s, "@") == 1 && strings.Contains(s, ".")
|
return strings.Count(s, "@") == 1 && strings.Contains(s, ".")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ package bootstrap
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@@ -79,10 +80,15 @@ func Load(configPath string) (*App, error) {
|
|||||||
return nil, fmt.Errorf("ensure schema: %w", err)
|
return nil, fmt.Errorf("ensure schema: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gob.Register(map[string]string{})
|
||||||
|
gob.Register([]string{})
|
||||||
|
gob.Register(time.Time{})
|
||||||
|
|
||||||
sessions := session.New(cfg)
|
sessions := session.New(cfg)
|
||||||
|
|
||||||
router := gin.New()
|
router := gin.New()
|
||||||
router.Use(gin.Logger(), gin.Recovery())
|
//router.Use(gin.Logger(), gin.Recovery())
|
||||||
|
router.Use(gin.Logger())
|
||||||
router.Static("/static", "./web/static")
|
router.Static("/static", "./web/static")
|
||||||
router.StaticFile("/favicon.ico", "./web/static/favicon.ico")
|
router.StaticFile("/favicon.ico", "./web/static/favicon.ico")
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package session
|
package session
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/gob"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -11,7 +10,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func New(cfg config.Config) *scs.SessionManager {
|
func New(cfg config.Config) *scs.SessionManager {
|
||||||
gob.Register(time.Time{})
|
|
||||||
s := scs.New()
|
s := scs.New()
|
||||||
|
|
||||||
// Lifetime (absolute max age)
|
// Lifetime (absolute max age)
|
||||||
|
|||||||
Reference in New Issue
Block a user