1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-01 15:18:20 +00:00

Ensure one can read the object with an action before running actionhandler

This commit is contained in:
Darren Shepherd
2018-01-16 12:50:29 -07:00
parent 76b1e1b679
commit e92239b78a

View File

@@ -5,6 +5,7 @@ import (
"sync"
"github.com/rancher/norman/api/access"
"github.com/rancher/norman/api/builtin"
"github.com/rancher/norman/api/handler"
"github.com/rancher/norman/api/writer"
@@ -220,8 +221,11 @@ func (s *Server) handle(rw http.ResponseWriter, req *http.Request) (*types.APICo
return apiRequest, nil
}
func handleAction(action *types.Action, request *types.APIContext) error {
return request.Schema.ActionHandler(request.Action, action, request)
func handleAction(action *types.Action, context *types.APIContext) error {
if err := access.ByID(context, context.Version, context.Type, context.ID, nil); err != nil {
return err
}
return context.Schema.ActionHandler(context.Action, action, context)
}
func (s *Server) handleError(apiRequest *types.APIContext, err error) {