diff options
author | Steve Manuel <nilslice@gmail.com> | 2017-03-15 13:28:53 -0700 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2017-03-15 13:28:53 -0700 |
commit | 5ec811b5d1899cfe538ed6d19c8a5ee01a553f03 (patch) | |
tree | 18a1a89076303acf3d2be40aa4ca371ed27ede3a /examples | |
parent | 95c7e73e2b8acf048ba61b3feab76dd5f46ac955 (diff) |
using api.ErrNoAuth return from auth check in examples
Diffstat (limited to 'examples')
-rw-r--r-- | examples/createable/content/song.go | 5 | ||||
-rw-r--r-- | examples/deleteable/content/song.go | 5 | ||||
-rw-r--r-- | examples/updateable/content/song.go | 5 |
3 files changed, 6 insertions, 9 deletions
diff --git a/examples/createable/content/song.go b/examples/createable/content/song.go index 74a6d4a..7473e91 100644 --- a/examples/createable/content/song.go +++ b/examples/createable/content/song.go @@ -8,6 +8,7 @@ import ( "github.com/ponzu-cms/ponzu/management/editor" "github.com/ponzu-cms/ponzu/system/admin/user" + "github.com/ponzu-cms/ponzu/system/api" "github.com/ponzu-cms/ponzu/system/item" ) @@ -110,9 +111,7 @@ func (s *Song) BeforeAPICreate(res http.ResponseWriter, req *http.Request) error // for example, this will check if the request was made by a CMS admin user: if !user.IsValid(req) { - addr := req.RemoteAddr - err := fmt.Errorf("request rejected, invalid user. IP: %s", addr) - return err + return api.ErrNoAuth } // you could then to data validation on the request post form, or do it in diff --git a/examples/deleteable/content/song.go b/examples/deleteable/content/song.go index 2198e33..b33bad0 100644 --- a/examples/deleteable/content/song.go +++ b/examples/deleteable/content/song.go @@ -8,6 +8,7 @@ import ( "github.com/ponzu-cms/ponzu/management/editor" "github.com/ponzu-cms/ponzu/system/admin/user" + "github.com/ponzu-cms/ponzu/system/api" "github.com/ponzu-cms/ponzu/system/item" ) @@ -87,9 +88,7 @@ func (s *Song) BeforeAPIDelete(res http.ResponseWriter, req *http.Request) error // for example, this will check if the request was made by a CMS admin user: if !user.IsValid(req) { - addr := req.RemoteAddr - err := fmt.Errorf("request rejected, invalid user. IP: %s", addr) - return err + return api.ErrNoAuth } // you could then to data validation on the request post form, or do it in diff --git a/examples/updateable/content/song.go b/examples/updateable/content/song.go index 947821c..a2dc7f8 100644 --- a/examples/updateable/content/song.go +++ b/examples/updateable/content/song.go @@ -9,6 +9,7 @@ import ( "github.com/ponzu-cms/ponzu/management/editor" "github.com/ponzu-cms/ponzu/system/admin/user" + "github.com/ponzu-cms/ponzu/system/api" "github.com/ponzu-cms/ponzu/system/item" ) @@ -88,9 +89,7 @@ func (s *Song) BeforeAPIUpdate(res http.ResponseWriter, req *http.Request) error // for example, this will check if the request was made by a CMS admin user: if !user.IsValid(req) { - addr := req.RemoteAddr - err := fmt.Errorf("request rejected, invalid user. IP: %s", addr) - return err + return api.ErrNoAuth } // you could then to data validation on the request post form, or do it in |