Skip to content

Commit fc3ef1f

Browse files
fix: replace all ctx.Org.IsOwner with proper IsOwnedBy method
The APIOrganization type doesn't have an IsOwner field. All ownership checks must use ctx.Org.Organization.IsOwnedBy(ctx, ctx.Doer.ID) to properly verify organizational ownership in API context.
1 parent 0106311 commit fc3ef1f

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

routers/api/v1/org/org_actions_permissions.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,12 @@ func ListCrossRepoAccess(ctx *context.APIContext) {
160160
// "200":
161161
// "$ref": "#/responses/CrossRepoAccessList"
162162

163-
if !ctx.Org.IsOwner {
163+
isOwner, err := ctx.Org.Organization.IsOwnedBy(ctx, ctx.Doer.ID)
164+
if err != nil {
165+
ctx.APIErrorInternal(err)
166+
return
167+
}
168+
if !isOwner {
164169
ctx.APIError(http.StatusForbidden, "Organization owner access required")
165170
return
166171
}
@@ -209,7 +214,12 @@ func AddCrossRepoAccess(ctx *context.APIContext) {
209214
// "403":
210215
// "$ref": "#/responses/forbidden"
211216

212-
if !ctx.Org.IsOwner {
217+
isOwner, err := ctx.Org.Organization.IsOwnedBy(ctx, ctx.Doer.ID)
218+
if err != nil {
219+
ctx.APIErrorInternal(err)
220+
return
221+
}
222+
if !isOwner {
213223
ctx.APIError(http.StatusForbidden, "Organization owner access required")
214224
return
215225
}
@@ -264,7 +274,12 @@ func DeleteCrossRepoAccess(ctx *context.APIContext) {
264274
// "403":
265275
// "$ref": "#/responses/forbidden"
266276

267-
if !ctx.Org.IsOwner {
277+
isOwner, err := ctx.Org.Organization.IsOwnedBy(ctx, ctx.Doer.ID)
278+
if err != nil {
279+
ctx.APIErrorInternal(err)
280+
return
281+
}
282+
if !isOwner {
268283
ctx.APIError(http.StatusForbidden, "Organization owner access required")
269284
return
270285
}

0 commit comments

Comments
 (0)