Skip to content

Commit

Permalink
using api.ErrNoAuth return from auth check in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
nilslice committed Mar 15, 2017
1 parent 95c7e73 commit 5ec811b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
5 changes: 2 additions & 3 deletions examples/createable/content/song.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions examples/deleteable/content/song.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions examples/updateable/content/song.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5ec811b

Please sign in to comment.