added admin options
This commit is contained in:
@@ -4,10 +4,12 @@ import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
||||
ory "github.com/ory/client-go"
|
||||
|
||||
"decor-by-hannahs/internal/db"
|
||||
)
|
||||
|
||||
func CatalogHandler(q *db.Queries, tmpl *template.Template) http.HandlerFunc {
|
||||
func CatalogHandler(q *db.Queries, tmpl *template.Template, oryClient *ory.APIClient) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
svcs, err := q.ListServices(r.Context())
|
||||
if err != nil {
|
||||
@@ -15,10 +17,17 @@ func CatalogHandler(q *db.Queries, tmpl *template.Template) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
type data struct {
|
||||
Services []db.Service
|
||||
ActivePage string
|
||||
Services []db.Service
|
||||
ActivePage string
|
||||
Authenticated bool
|
||||
OryLoginURL string
|
||||
}
|
||||
if err := tmpl.ExecuteTemplate(w, "catalog.tmpl", data{Services: svcs, ActivePage: "catalog"}); err != nil {
|
||||
if err := tmpl.ExecuteTemplate(w, "catalog.tmpl", data{
|
||||
Services: svcs,
|
||||
ActivePage: "catalog",
|
||||
Authenticated: isAuthenticated(r, oryClient),
|
||||
OryLoginURL: "/login",
|
||||
}); err != nil {
|
||||
http.Error(w, "Failed to render page", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user