diff --git a/internal/handlers/debug.go b/internal/handlers/debug.go index 81fc446..baaac33 100644 --- a/internal/handlers/debug.go +++ b/internal/handlers/debug.go @@ -1,6 +1,7 @@ package handlers import ( + "log" "net/http" "git.jamestombleson.com/jtom38/newsbot-portal/internal/domain" @@ -10,14 +11,25 @@ import ( ) func (h *Handler) DebugCookies(c echo.Context) error { - user, _ := c.Cookie(domain.CookieUser) - token, _ := c.Cookie(domain.CookieToken) - refresh, _ := c.Cookie(domain.CookieRefreshToken) + model := models.DebugCookiesViewModel{} - model := models.DebugCookiesViewModel{ - Username: user.Value, - Token: token.Value, - RefreshToken: refresh.Value, + allCookies := c.Cookies() + log.Print(allCookies) + + user, err := c.Cookie(domain.CookieUser) + if err == nil { + model.Username = user.Value } + + token, err := c.Cookie(domain.CookieToken) + if err == nil { + model.Token = token.Value + } + + refresh, err := c.Cookie(domain.CookieRefreshToken) + if err == nil { + model.RefreshToken = refresh.Value + } + return Render(c, http.StatusOK, debug.Cookies(model)) } diff --git a/internal/views/debug/cookies.templ b/internal/views/debug/cookies.templ index 922627b..0f7d5e1 100644 --- a/internal/views/debug/cookies.templ +++ b/internal/views/debug/cookies.templ @@ -5,8 +5,12 @@ import "git.jamestombleson.com/jtom38/newsbot-portal/internal/models" templ Cookies(vm models.DebugCookiesViewModel) { @layout.WithTemplate() { +
Token: { vm.Token } +
+RefreshToken: { vm.RefreshToken } +
UserName: { vm.Username } } }