Start adding some logging

This commit is contained in:
Carl Pearson
2024-09-21 06:22:34 -06:00
parent 62d9ebf74b
commit dc04468f7c
6 changed files with 72 additions and 13 deletions

View File

@@ -51,17 +51,28 @@ func registerPostHandler(c echo.Context) error {
return c.Redirect(http.StatusSeeOther, "/login")
}
func loginHandler(c echo.Context) error {
return c.Render(http.StatusOK, "login.html", nil)
}
func homeHandler(c echo.Context) error {
// redirect to /videos if logged in
session, err := store.Get(c.Request(), "session")
if err == nil {
_, ok := session.Values["user_id"]
if ok {
fmt.Println("homeHandler: session contains user_id. Redirect to /video")
return c.Redirect(http.StatusSeeOther, "/videos")
}
}
return c.Render(http.StatusOK, "home.html",
map[string]interface{}{
"Footer": makeFooter(),
})
}
func loginHandler(c echo.Context) error {
return c.Render(http.StatusOK, "login.html", nil)
}
func loginPostHandler(c echo.Context) error {
username := c.FormValue("username")
password := c.FormValue("password")