pollo/pages/dashboard.go

31 lines
583 B
Go
Raw Normal View History

2024-06-27 21:23:51 -06:00
package pages
import (
"pollo/lib"
"github.com/labstack/echo/v4"
)
type DashboardProps struct {
2024-06-27 21:51:00 -06:00
IsLoggedIn bool
2024-06-28 00:35:58 -06:00
Email string
2024-06-27 21:23:51 -06:00
}
func Dashboard(c echo.Context) error {
2024-06-28 00:35:58 -06:00
currentSession, error := lib.GetSessionCookie(c.Request(), "session")
if error != nil {
return c.Redirect(302, "/signin")
}
2024-06-27 21:51:00 -06:00
props := DashboardProps{
IsLoggedIn: lib.IsSignedIn(c),
2024-06-28 00:35:58 -06:00
Email: currentSession.Email,
2024-06-27 21:51:00 -06:00
}
2024-06-27 21:23:51 -06:00
// Specify the partials used by this page
partials := []string{"header"}
// Render the template
return lib.RenderTemplate(c.Response().Writer, "base", partials, props)
}