From 60188b064cb47e9d1324aece91444d2dd13f9adf Mon Sep 17 00:00:00 2001 From: Stephanie Gredell Date: Sat, 16 Nov 2024 04:31:39 -0500 Subject: [PATCH] fix passing isLoggedIn to header.html --- pages/welcome.go | 7 ++++++- pages/wishlist.go | 6 +++++- templates/goals.html | 2 +- templates/header.html | 4 ++-- templates/index.html | 2 +- templates/welcome.html | 14 +------------- 6 files changed, 16 insertions(+), 19 deletions(-) diff --git a/pages/welcome.go b/pages/welcome.go index 88b1fc2..f60241c 100644 --- a/pages/welcome.go +++ b/pages/welcome.go @@ -1,12 +1,17 @@ package pages import ( + "fmt" "github.com/gin-gonic/gin" "net/http" + "sponsorahacker/utils" ) func Welcome(c *gin.Context) { + isLoggedIn := utils.CheckIfLoggedIn(c) + fmt.Println("isLoggedIn:", isLoggedIn) c.HTML(http.StatusOK, "welcome.html", gin.H{ - "title": "Sponsor A Hacker", + "title": "Sponsor A Hacker", + "isLoggedIn": isLoggedIn, }) } diff --git a/pages/wishlist.go b/pages/wishlist.go index eb944af..ef54948 100644 --- a/pages/wishlist.go +++ b/pages/wishlist.go @@ -3,10 +3,14 @@ package pages import ( "github.com/gin-gonic/gin" "net/http" + "sponsorahacker/utils" ) func Goals(c *gin.Context) { + isLoggedIn := utils.CheckIfLoggedIn(c) + c.HTML(http.StatusOK, "goals.html", gin.H{ - "title": "Sponsor A Hacker", + "title": "Sponsor A Hacker", + "isLoggedIn": isLoggedIn, }) } diff --git a/templates/goals.html b/templates/goals.html index 6079765..d1ed32f 100644 --- a/templates/goals.html +++ b/templates/goals.html @@ -155,7 +155,7 @@ -{{template "pageheader"}} +{{template "pageheader" . }}

Manage Your Goals

diff --git a/templates/header.html b/templates/header.html index b99930e..c86cb91 100644 --- a/templates/header.html +++ b/templates/header.html @@ -4,8 +4,8 @@

Sponsor A Hacker

- - {{if eq . false}} +isLoggedIn = {{.isLoggedIn}} + {{if eq .isLoggedIn false}} {{ else }} diff --git a/templates/index.html b/templates/index.html index 39c9809..c58cf9b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -4,7 +4,7 @@ -{{template "pageheader" .isLoggedIn}} +{{template "pageheader" . }}

Set Goals. Support Dreams. Build Community.

Our platform connects aspiring tech professionals with a supportive community eager to help them succeed. diff --git a/templates/welcome.html b/templates/welcome.html index 9463afc..a6b45c0 100644 --- a/templates/welcome.html +++ b/templates/welcome.html @@ -82,19 +82,7 @@ -

- -

- {{ .title }} -

- - {{if eq .isLoggedIn false}} - - {{ else }} - - {{ end }} - -
+{{template "pageheader" . }}