Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
12 changes: 12 additions & 0 deletions routers/web/repo/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,18 @@ func CollaborationPost(ctx *context.Context) {
return
}

// find the owner team of the organization the repo belongs too and
// check if the user we're trying to add is an owner.
if ctx.Repo.Repository.Owner.IsOrganization() {
if isOwner, err := organization.IsOrganizationOwner(ctx, ctx.Repo.Repository.Owner.ID, u.ID); err != nil {
ctx.ServerError("IsOrganizationOwner", err)
return
} else if isOwner {
ctx.Redirect(setting.AppSubURL + ctx.Req.URL.EscapedPath())
return
}
}

if err = models.AddCollaborator(ctx.Repo.Repository, u); err != nil {
ctx.ServerError("AddCollaborator", err)
return
Expand Down