features/cookies-maybe #2

Merged
jtom38 merged 4 commits from features/cookies-maybe into main 2024-04-13 11:53:29 -07:00
2 changed files with 25 additions and 7 deletions
Showing only changes of commit f955be507a - Show all commits

View File

@ -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))
}

View File

@ -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())
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())
//}