add pretty register endpoint

This commit is contained in:
paul 2020-07-19 11:52:26 +02:00
commit c0ef92fa94
11 changed files with 352 additions and 13 deletions

View file

@ -25,14 +25,12 @@ func LoadTemplatesFS(fs http.FileSystem, dir string) Templates {
if err != nil {
log.Fatal(err)
}
//log.Printf("Loaded %d layouts", len(layouts))
includes, err := vfspath.Glob(fs, dir+"/includes/*.tmpl")
if err != nil {
log.Fatal(err)
}
//log.Printf("Loaded %d includes", len(includes))
funcs := getFuncMap() // generate function map

View file

@ -104,3 +104,28 @@ func (h *Handlers) LoginPageHandler(w http.ResponseWriter, r *http.Request) {
h.Templates().Get("auth_login.tmpl").Execute(w, h.commonRenderContext(r))
}
// RegisterPageHandler renders the login page, and sets session cookies
// on successful authentication.
func (h *Handlers) RegisterPageHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodPost {
type RegisterForm struct {
Email string
}
registerForm := RegisterForm{
Email: r.PostFormValue("email"),
}
_ = registerForm
{
context := h.commonRenderContext(r)
context["Errors"] = []string{"registration disabled"}
h.Templates().Get("auth_register.tmpl").Execute(w, context)
return
}
}
h.Templates().Get("auth_register.tmpl").Execute(w, h.commonRenderContext(r))
}

View file

@ -23,6 +23,9 @@ func registerRoutes(ac *app.App, r chi.Router) {
r.Get("/login", h.LoginPageHandler)
r.Post("/login", h.LoginPageHandler)
r.Get("/signup", h.RegisterPageHandler)
r.Post("/signup", h.RegisterPageHandler)
r.Get("/", h.LandingPageHandler)
r.Route("/app", func(r chi.Router) {