fix(stacks): address review comments EE-3683

This commit is contained in:
testa113
2022-08-03 17:43:17 +12:00
parent 790eb8c39e
commit 56ba5f896e
3 changed files with 3 additions and 6 deletions

View File

@@ -144,9 +144,7 @@ func (handler *Handler) userCanManageStacks(securityContext *security.Restricted
return false, fmt.Errorf("Failed to get user from the database: %w", err)
}
if !canCreate {
return false, nil
}
return canCreate, nil
}
return true, nil
}

View File

@@ -5,7 +5,6 @@ import (
"net/http"
"time"
"github.com/pkg/errors"
httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/request"
"github.com/portainer/libhttp/response"
@@ -96,7 +95,7 @@ func (handler *Handler) stackAssociate(w http.ResponseWriter, r *http.Request) *
}
if !canManage {
errMsg := "Stack management is disabled for non-admin users"
return &httperror.HandlerError{StatusCode: http.StatusForbidden, Message: errMsg, Err: errors.New(errMsg)}
return &httperror.HandlerError{StatusCode: http.StatusForbidden, Message: errMsg, Err: fmt.Errorf(errMsg)}
}
stack.EndpointID = portainer.EndpointID(endpointID)

View File

@@ -109,7 +109,7 @@ func (handler *Handler) stackDelete(w http.ResponseWriter, r *http.Request) *htt
}
if !canManage {
errMsg := "Stack deletion is disabled for non-admin users"
return &httperror.HandlerError{StatusCode: http.StatusForbidden, Message: errMsg, Err: errors.New(errMsg)}
return &httperror.HandlerError{StatusCode: http.StatusForbidden, Message: errMsg, Err: fmt.Errorf(errMsg)}
}
// stop scheduler updates of the stack before removal