Browse Source

fix passing isLoggedIn to header.html

master
Stephanie Gredell 1 year ago
parent
commit
60188b064c
  1. 7
      pages/welcome.go
  2. 6
      pages/wishlist.go
  3. 2
      templates/goals.html
  4. 4
      templates/header.html
  5. 2
      templates/index.html
  6. 14
      templates/welcome.html

7
pages/welcome.go

@ -1,12 +1,17 @@
package pages package pages
import ( import (
"fmt"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"net/http" "net/http"
"sponsorahacker/utils"
) )
func Welcome(c *gin.Context) { func Welcome(c *gin.Context) {
isLoggedIn := utils.CheckIfLoggedIn(c)
fmt.Println("isLoggedIn:", isLoggedIn)
c.HTML(http.StatusOK, "welcome.html", gin.H{ c.HTML(http.StatusOK, "welcome.html", gin.H{
"title": "Sponsor A Hacker", "title": "Sponsor A Hacker",
"isLoggedIn": isLoggedIn,
}) })
} }

6
pages/wishlist.go

@ -3,10 +3,14 @@ package pages
import ( import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"net/http" "net/http"
"sponsorahacker/utils"
) )
func Goals(c *gin.Context) { func Goals(c *gin.Context) {
isLoggedIn := utils.CheckIfLoggedIn(c)
c.HTML(http.StatusOK, "goals.html", gin.H{ c.HTML(http.StatusOK, "goals.html", gin.H{
"title": "Sponsor A Hacker", "title": "Sponsor A Hacker",
"isLoggedIn": isLoggedIn,
}) })
} }

2
templates/goals.html

@ -155,7 +155,7 @@
</style> </style>
</head> </head>
<body> <body>
{{template "pageheader"}} {{template "pageheader" . }}
<div class="wishlist-container"> <div class="wishlist-container">
<header class="wishlist-page-header"> <header class="wishlist-page-header">
<h1>Manage Your Goals</h1> <h1>Manage Your Goals</h1>

4
templates/header.html

@ -4,8 +4,8 @@
<h1 class="title"> <h1 class="title">
Sponsor A Hacker Sponsor A Hacker
</h1> </h1>
isLoggedIn = {{.isLoggedIn}}
{{if eq . false}} {{if eq .isLoggedIn false}}
<a href="/login" class="login-banner-link">Login</a> <a href="/login" class="login-banner-link">Login</a>
{{ else }} {{ else }}
<a href="auth/logout/twitch" class="login-banner-link">Logout</a> <a href="auth/logout/twitch" class="login-banner-link">Logout</a>

2
templates/index.html

@ -4,7 +4,7 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
</head> </head>
<body> <body>
{{template "pageheader" .isLoggedIn}} {{template "pageheader" . }}
<div class="content"> <div class="content">
<h2 class="difference">Set Goals. Support Dreams. Build Community.</h2> <h2 class="difference">Set Goals. Support Dreams. Build Community.</h2>
<p class="product-description">Our platform connects aspiring tech professionals with a supportive community eager to help them succeed. <p class="product-description">Our platform connects aspiring tech professionals with a supportive community eager to help them succeed.

14
templates/welcome.html

@ -82,19 +82,7 @@
</style> </style>
</head> </head>
<body> <body>
<div class="header"> {{template "pageheader" . }}
<img src="assets/images/logo.jpg" class="logo"/>
<h1 class="title">
{{ .title }}
</h1>
{{if eq .isLoggedIn false}}
<a href="/login" class="login-banner-link">Login</a>
{{ else }}
<a href="auth/logout/twitch" class="login-banner-link">Logout</a>
{{ end }}
</div>
<div class="dashboard-container"> <div class="dashboard-container">
<div class="dashboard-container"> <div class="dashboard-container">
<div class="welcome"> <div class="welcome">

Loading…
Cancel
Save