updated handlers with the new view folder and testing how to validate jwt and cookies
This commit is contained in:
parent
04acb45c76
commit
f955be507a
@ -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))
|
||||
}
|
||||
|
@ -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())
|
||||
//}
|
||||
|
Loading…
Reference in New Issue
Block a user