fixed some login and booking bugs

This commit is contained in:
tumillanino
2025-10-28 13:36:05 +11:00
parent dad3ec655f
commit 5d7f0a8eb3
11 changed files with 402 additions and 141 deletions

View File

@@ -8,10 +8,12 @@ import (
"path/filepath"
"sort"
ory "github.com/ory/client-go"
"decor-by-hannahs/internal/db"
)
func HomeHandler(q *db.Queries, tmpl *template.Template) http.HandlerFunc {
func HomeHandler(q *db.Queries, tmpl *template.Template, oryClient *ory.APIClient) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
log.Printf("HomeHandler called: method=%s path=%s", r.Method, r.URL.Path)
if r.URL.Path != "/" {
@@ -42,11 +44,19 @@ func HomeHandler(q *db.Queries, tmpl *template.Template) http.HandlerFunc {
})
type data struct {
Title string
Photos []Photo
ActivePage string
Title string
Photos []Photo
ActivePage string
Authenticated bool
OryLoginURL string
}
if err := tmpl.ExecuteTemplate(w, "home.tmpl", data{Title: "Home", Photos: photos, ActivePage: "home"}); err != nil {
if err := tmpl.ExecuteTemplate(w, "home.tmpl", data{
Title: "Home",
Photos: photos,
ActivePage: "home",
Authenticated: isAuthenticated(r, oryClient),
OryLoginURL: "/login",
}); err != nil {
log.Printf("Error executing home.tmpl: %v", err)
http.Error(w, "Failed to render page", http.StatusInternalServerError)
}