Skip to content

Commit 0106311

Browse files
fix: use correct API context methods for org ownership checks
- Replace direct ctx.Org.IsOwner with ctx.Org.Organization.IsOwnedBy() - Fix ctx.ParamsInt64 to ctx.PathParamInt64 for route parameters - Ensures proper error handling for ownership verification
1 parent 65617bf commit 0106311

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

routers/api/v1/org/org_actions_permissions.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ func GetActionsPermissions(ctx *context.APIContext) {
3434
// Organization settings are more sensitive than repo settings because they
3535
// affect ALL repositories in the org. We should be extra careful here.
3636
// Only org owners should be able to modify these settings.
37-
if !ctx.Org.IsOwner {
37+
isOwner, err := ctx.Org.Organization.IsOwnedBy(ctx, ctx.Doer.ID)
38+
if err != nil {
39+
ctx.APIError(http.StatusInternalServerError, err)
40+
return
41+
} else if !isOwner {
3842
ctx.APIError(http.StatusForbidden, "You must be an organization owner")
3943
return
4044
}
@@ -86,7 +90,11 @@ func UpdateActionsPermissions(ctx *context.APIContext) {
8690
// "403":
8791
// "$ref": "#/responses/forbidden"
8892

89-
if !ctx.Org.IsOwner {
93+
isOwner, err := ctx.Org.Organization.IsOwnedBy(ctx, ctx.Doer.ID)
94+
if err != nil {
95+
ctx.APIError(http.StatusInternalServerError, err)
96+
return
97+
} else if !isOwner {
9098
ctx.APIError(http.StatusForbidden, "Organization owner access required")
9199
return
92100
}
@@ -261,7 +269,7 @@ func DeleteCrossRepoAccess(ctx *context.APIContext) {
261269
return
262270
}
263271

264-
ruleID := ctx.ParamsInt64("id")
272+
ruleID := ctx.PathParamInt64("id")
265273

266274
// Security check: Verify the rule belongs to this org before deleting
267275
// We don't want one org to be able to delete another org's rules

0 commit comments

Comments
 (0)