mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: remove excess calls to prepareSQLFilter for workspace and template endpoints (#27248)
This commit is contained in:
+3
-10
@@ -172,15 +172,6 @@ func (api *API) workspaces(rw http.ResponseWriter, r *http.Request) {
|
||||
filter.OwnerUsername = ""
|
||||
}
|
||||
|
||||
prepared, err := api.HTTPAuth.AuthorizeSQLFilter(r, policy.ActionRead, rbac.ResourceWorkspace.Type)
|
||||
if err != nil {
|
||||
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
|
||||
Message: "Internal error preparing sql filter.",
|
||||
Detail: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// To show the requester's favorite workspaces first, we pass their userID and compare it to
|
||||
// the workspace owner_id when ordering the rows.
|
||||
filter.RequesterID = apiKey.UserID
|
||||
@@ -188,7 +179,9 @@ func (api *API) workspaces(rw http.ResponseWriter, r *http.Request) {
|
||||
// We need the technical row to present the correct count on every page.
|
||||
filter.WithSummary = true
|
||||
|
||||
workspaceRows, err := api.Database.GetAuthorizedWorkspaces(ctx, filter, prepared)
|
||||
// GetWorkspaces authorizes the query itself, so we don't prepare a SQL
|
||||
// filter here.
|
||||
workspaceRows, err := api.Database.GetWorkspaces(ctx, filter)
|
||||
if err != nil {
|
||||
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
|
||||
Message: "Internal error fetching workspaces.",
|
||||
|
||||
Reference in New Issue
Block a user