newsbot-portal/internal/handlers/debug.go

36 lines
780 B
Go
Raw Permalink Normal View History

2024-05-12 10:45:16 -07:00
package handlers
import (
2024-05-18 22:37:46 -07:00
"log"
2024-05-12 10:45:16 -07:00
"net/http"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/domain"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/views/debug"
"github.com/labstack/echo/v4"
)
func (h *Handler) DebugCookies(c echo.Context) error {
2024-05-18 22:37:46 -07:00
model := models.DebugCookiesViewModel{}
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
2024-05-12 10:45:16 -07:00
}
2024-05-18 22:37:46 -07:00
refresh, err := c.Cookie(domain.CookieRefreshToken)
if err == nil {
model.RefreshToken = refresh.Value
}
2024-05-12 10:45:16 -07:00
return Render(c, http.StatusOK, debug.Cookies(model))
}