summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--system/admin/handlers.go17
-rw-r--r--system/api/create.go13
2 files changed, 30 insertions, 0 deletions
diff --git a/system/admin/handlers.go b/system/admin/handlers.go
index babcff1..d579b2f 100644
--- a/system/admin/handlers.go
+++ b/system/admin/handlers.go
@@ -1926,6 +1926,23 @@ func editHandler(res http.ResponseWriter, req *http.Request) {
return
}
+ // Let's be nice and make a proper item for the Hookable methods
+ dec := schema.NewDecoder()
+ dec.IgnoreUnknownKeys(true)
+ dec.SetAliasTag("json")
+ err = dec.Decode(post, req.PostForm)
+ if err != nil {
+ log.Println("Error decoding post form for edit handler:", t, err)
+ res.WriteHeader(http.StatusBadRequest)
+ errView, err := Error400()
+ if err != nil {
+ return
+ }
+
+ res.Write(errView)
+ return
+ }
+
if cid == "-1" {
err = hook.BeforeAdminCreate(res, req)
if err != nil {
diff --git a/system/api/create.go b/system/api/create.go
index 3328bd6..3b748cc 100644
--- a/system/api/create.go
+++ b/system/api/create.go
@@ -12,6 +12,8 @@ import (
"github.com/ponzu-cms/ponzu/system/admin/upload"
"github.com/ponzu-cms/ponzu/system/db"
"github.com/ponzu-cms/ponzu/system/item"
+
+ "github.com/gorilla/schema"
)
// Createable accepts or rejects external POST requests to endpoints such as:
@@ -131,6 +133,17 @@ func createContentHandler(res http.ResponseWriter, req *http.Request) {
return
}
+ // Let's be nice and make a proper item for the Hookable methods
+ dec := schema.NewDecoder()
+ dec.IgnoreUnknownKeys(true)
+ dec.SetAliasTag("json")
+ err = dec.Decode(post, req.PostForm)
+ if err != nil {
+ log.Println("Error decoding post form for edit handler:", t, err)
+ res.WriteHeader(http.StatusBadRequest)
+ return
+ }
+
err = hook.BeforeAPICreate(res, req)
if err != nil {
log.Println("[Create] error calling BeforeAccept:", err)