Skip to content

Commit

Permalink
EditOrg: respect RepoAdminChangeTeamAccess (fix go-gitea#16013)
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 committed Jun 17, 2021
1 parent bfe711e commit 8d73de8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion modules/structs/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type CreateOrgOption struct {
RepoAdminChangeTeamAccess bool `json:"repo_admin_change_team_access"`
}

// TODO: make EditOrgOption fields optional after https://gitea.com/go-chi/binding/pulls/5 got merged

// EditOrgOption options for editing an organization
type EditOrgOption struct {
FullName string `json:"full_name"`
Expand All @@ -40,5 +42,5 @@ type EditOrgOption struct {
// possible values are `public`, `limited` or `private`
// enum: public,limited,private
Visibility string `json:"visibility" binding:"In(,public,limited,private)"`
RepoAdminChangeTeamAccess bool `json:"repo_admin_change_team_access"`
RepoAdminChangeTeamAccess *bool `json:"repo_admin_change_team_access"`
}
8 changes: 7 additions & 1 deletion routers/api/v1/org/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,13 @@ func Edit(ctx *context.APIContext) {
if form.Visibility != "" {
org.Visibility = api.VisibilityModes[form.Visibility]
}
if err := models.UpdateUserCols(org, "full_name", "description", "website", "location", "visibility"); err != nil {
if form.RepoAdminChangeTeamAccess != nil {
org.RepoAdminChangeTeamAccess = *form.RepoAdminChangeTeamAccess
}
if err := models.UpdateUserCols(org,
"full_name", "description", "website", "location",
"visibility", "repo_admin_change_team_access",
); err != nil {
ctx.Error(http.StatusInternalServerError, "EditOrganization", err)
return
}
Expand Down

0 comments on commit 8d73de8

Please sign in to comment.