adding some debug

This commit is contained in:
James Tombleson 2024-05-18 22:37:46 -07:00
parent db6d1cab0a
commit dc461bcb67
2 changed files with 23 additions and 7 deletions

View File

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

View File

@ -5,8 +5,12 @@ import "git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
templ Cookies(vm models.DebugCookiesViewModel) {
@layout.WithTemplate() {
<p>
Token: { vm.Token }
</p>
<p>
RefreshToken: { vm.RefreshToken }
</p>
UserName: { vm.Username }
}
}