Skip to content
Merged
10 changes: 10 additions & 0 deletions routers/web/repo/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,16 @@ 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.
teams, err := organization.GetRepoTeams(ctx, ctx.Repo.Repository)
for _, team := range teams {
if team.IsOwnerTeam() && team.IsMember(u.ID) {
ctx.Redirect(setting.AppSubURL + ctx.Req.URL.EscapedPath())
return
}
}

if !u.IsActive {
ctx.Flash.Error(ctx.Tr("repo.settings.add_collaborator_inactive_user"))
ctx.Redirect(setting.AppSubURL + ctx.Req.URL.EscapedPath())
Expand Down