mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
chore: fetch workspaces by username with organization permissions (#17707)
Closes https://github.com/coder/coder/issues/17691 `ExtractOrganizationMembersParam` will allow fetching a user with only organization permissions. If the user belongs to 0 orgs, then the user "does not exist" from an org perspective. But if you are a site-wide admin, then the user does exist.
This commit is contained in:
@ -232,7 +232,7 @@ func (api *API) workspaceBuilds(rw http.ResponseWriter, r *http.Request) {
|
||||
// @Router /users/{user}/workspace/{workspacename}/builds/{buildnumber} [get]
|
||||
func (api *API) workspaceBuildByBuildNumber(rw http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
owner := httpmw.UserParam(r)
|
||||
mems := httpmw.OrganizationMembersParam(r)
|
||||
workspaceName := chi.URLParam(r, "workspacename")
|
||||
buildNumber, err := strconv.ParseInt(chi.URLParam(r, "buildnumber"), 10, 32)
|
||||
if err != nil {
|
||||
@ -244,7 +244,7 @@ func (api *API) workspaceBuildByBuildNumber(rw http.ResponseWriter, r *http.Requ
|
||||
}
|
||||
|
||||
workspace, err := api.Database.GetWorkspaceByOwnerIDAndName(ctx, database.GetWorkspaceByOwnerIDAndNameParams{
|
||||
OwnerID: owner.ID,
|
||||
OwnerID: mems.UserID(),
|
||||
Name: workspaceName,
|
||||
})
|
||||
if httpapi.Is404Error(err) {
|
||||
|
Reference in New Issue
Block a user