diff --git a/handlers/auth.go b/handlers/auth.go index 29d4c73..5b152a2 100644 --- a/handlers/auth.go +++ b/handlers/auth.go @@ -1,9 +1,10 @@ package handlers import ( + "log" "net/http" - "templ-test/views" "templ-test/views/auth" + "templ-test/views/home" "github.com/labstack/echo/v4" ) @@ -39,10 +40,17 @@ func (h *Handlers) AuthLoginPost(c echo.Context) error { c.SetCookie(cookie) // render - return Render(c, http.StatusOK, views.Home()) + return Render(c, http.StatusOK, home.Home()) } func (h *Handlers) AuthShowCookies(c echo.Context) error { + claims, err := ValidateJwt(c, h.cfg.SharedApiSecret, h.cfg.ApiServerUri) + if err != nil { + return Render(c, http.StatusInternalServerError, home.Error(err)) + } + log.Println(claims) + cookies := GetCookieValues(c) + return Render(c, http.StatusOK, auth.ShowCookie(cookies)) } diff --git a/handlers/home.go b/handlers/home.go index aac02ef..d35c8df 100644 --- a/handlers/home.go +++ b/handlers/home.go @@ -2,15 +2,25 @@ package handlers import ( "net/http" - "templ-test/views" + "templ-test/views/home" "github.com/labstack/echo/v4" ) func (h *Handlers) HomeHandler(c echo.Context) error { - return Render(c, http.StatusOK, views.Home()) + return Render(c, http.StatusOK, home.Home()) } -func (h *Handlers) ListHandler(c echo.Context) error { - return Render(c, http.StatusOK, views.List()) -} \ No newline at end of file +func (h *Handlers) Settings(c echo.Context) error { + return Render(c, http.StatusOK, home.UserSettings()) +} + +func (h *Handlers) SettingsPost(c echo.Context) error { + // take in the updated values from he user and write the cookies... tbd + + return Render(c, http.StatusOK, home.UserSettings()) +} + +//func (h *Handlers) ListHandler(c echo.Context) error { +// return Render(c, http.StatusOK, views.List()) +//}