add pretty register endpoint
This commit is contained in:
parent
28f5a12f94
commit
c0ef92fa94
11 changed files with 352 additions and 13 deletions
internal
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue