added admin options
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
"path/filepath"
|
||||
"sort"
|
||||
|
||||
ory "github.com/ory/client-go"
|
||||
|
||||
"decor-by-hannahs/internal/db"
|
||||
)
|
||||
|
||||
@@ -15,7 +17,7 @@ type Photo struct {
|
||||
Caption string
|
||||
}
|
||||
|
||||
func GalleryHandler(q *db.Queries, tmpl *template.Template) http.HandlerFunc {
|
||||
func GalleryHandler(q *db.Queries, tmpl *template.Template, oryClient *ory.APIClient) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var photos []Photo
|
||||
|
||||
@@ -40,10 +42,17 @@ func GalleryHandler(q *db.Queries, tmpl *template.Template) http.HandlerFunc {
|
||||
})
|
||||
|
||||
type data struct {
|
||||
Photos []Photo
|
||||
ActivePage string
|
||||
Photos []Photo
|
||||
ActivePage string
|
||||
Authenticated bool
|
||||
OryLoginURL string
|
||||
}
|
||||
if err := tmpl.ExecuteTemplate(w, "gallery.tmpl", data{Photos: photos, ActivePage: "gallery"}); err != nil {
|
||||
if err := tmpl.ExecuteTemplate(w, "gallery.tmpl", data{
|
||||
Photos: photos,
|
||||
ActivePage: "gallery",
|
||||
Authenticated: isAuthenticated(r, oryClient),
|
||||
OryLoginURL: "/login",
|
||||
}); err != nil {
|
||||
http.Error(w, "Failed to render page", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user