func signupHandler(c *util.Context) error { selectedPlan := c.Request.FormValue("plan") return c.T("s", "signup").Execute(c.Writer, map[string]string{ "pricingUrl": webUrl + "pricing", "docsUrl": webUrl + "docs", "blogUrl": blogUrl, "selectedPlan": selectedPlan, }) }
func loginHandler(c *util.Context) error { send := func(invalid bool) error { return c.T("l", "login").Execute(c.Writer, map[string]interface{}{ "context": c, "next": c.Request.FormValue("next"), "username": c.Request.FormValue("username"), "invalid": invalid, }) } // Simple get if c.Request.Method == "GET" { fmt.Println("get") return send(false) } // Form validation pass form := loginForm(c.Request) if !form.IsValid() { fmt.Println("invalid") return send(true) } user, err := data.Login(c.Database, c.Request.FormValue("username"), c.Request.FormValue("password")) // Login failed -> bad creds if err != nil { fmt.Println(err) return send(true) } // Log him in! c.Session.Values["user"] = user.ID if c.Request.FormValue("next") != "" { c.Redirect(c.Request.FormValue("next")) } else { c.Redirect("/dashboard") } return nil }
func dashboardHandler(c *util.Context) error { return c.T("a", "account/settings").Execute(c.Writer, map[string]interface{}{ "context": c, }) }