0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-15 04:13:35 +02:00

move group routes that don't depend on the org path parameter out of the /orgs/{org} route group

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2025-08-14 15:36:43 -04:00
parent 8fce091a48
commit 4bf17e9b21
No known key found for this signature in database
GPG Key ID: 924A5F6AF051E87C
2 changed files with 7 additions and 23 deletions

View File

@ -508,7 +508,6 @@ func reqGroupMembership(mode perm.AccessMode, needsCreatePerm bool) func(ctx *co
return return
} }
canAccess, err := g.CanAccessAtLevel(ctx, ctx.Doer, mode) canAccess, err := g.CanAccessAtLevel(ctx, ctx.Doer, mode)
if err != nil { if err != nil {
ctx.APIErrorInternal(err) ctx.APIErrorInternal(err)
return return
@ -1208,7 +1207,7 @@ func Routes() *web.Router {
m.Combo("").Get(reqAnyRepoReader(), repo.Get). m.Combo("").Get(reqAnyRepoReader(), repo.Get).
Delete(reqToken(), reqOwner(), repo.Delete). Delete(reqToken(), reqOwner(), repo.Delete).
Patch(reqToken(), reqAdmin(), bind(api.EditRepoOption{}), repo.Edit) Patch(reqToken(), reqAdmin(), bind(api.EditRepoOption{}), repo.Edit)
m.Post("/groups/move", reqToken(), bind(api.EditGroupOption{}), reqOrgMembership(), reqGroupMembership(perm.AccessModeWrite, false), repo.MoveRepoToGroup) m.Post("/groups/move", reqToken(), bind(api.MoveGroupOption{}), reqOrgMembership(), reqGroupMembership(perm.AccessModeWrite, false), repo.MoveRepoToGroup)
m.Post("/generate", reqToken(), reqRepoReader(unit.TypeCode), bind(api.GenerateRepoOption{}), repo.Generate) m.Post("/generate", reqToken(), reqRepoReader(unit.TypeCode), bind(api.GenerateRepoOption{}), repo.Generate)
m.Group("/transfer", func() { m.Group("/transfer", func() {
m.Post("", reqOwner(), bind(api.TransferRepoOption{}), repo.Transfer) m.Post("", reqOwner(), bind(api.TransferRepoOption{}), repo.Transfer)
@ -1718,7 +1717,6 @@ func Routes() *web.Router {
}, reqToken(), reqOrgOwnership()) }, reqToken(), reqOrgOwnership())
m.Group("/groups", func() { m.Group("/groups", func() {
m.Post("/new", reqToken(), reqGroupMembership(perm.AccessModeWrite, true), group.NewGroup) m.Post("/new", reqToken(), reqGroupMembership(perm.AccessModeWrite, true), group.NewGroup)
m.Post("/{group_id}/move", reqToken(), reqGroupMembership(perm.AccessModeWrite, false), group.MoveGroup)
}) })
}, tokenRequiresScopes(auth_model.AccessTokenScopeCategoryOrganization), orgAssignment(true), checkTokenPublicOnly()) }, tokenRequiresScopes(auth_model.AccessTokenScopeCategoryOrganization), orgAssignment(true), checkTokenPublicOnly())
m.Group("/teams/{teamid}", func() { m.Group("/teams/{teamid}", func() {
@ -1806,8 +1804,9 @@ func Routes() *web.Router {
Get(reqGroupMembership(perm.AccessModeRead, false), group.GetGroup). Get(reqGroupMembership(perm.AccessModeRead, false), group.GetGroup).
Patch(reqToken(), reqGroupMembership(perm.AccessModeWrite, false), bind(api.EditGroupOption{}), group.EditGroup). Patch(reqToken(), reqGroupMembership(perm.AccessModeWrite, false), bind(api.EditGroupOption{}), group.EditGroup).
Delete(reqToken(), reqGroupMembership(perm.AccessModeAdmin, false), group.DeleteGroup) Delete(reqToken(), reqGroupMembership(perm.AccessModeAdmin, false), group.DeleteGroup)
m.Post("/move", reqToken(), reqGroupMembership(perm.AccessModeWrite, false), bind(api.MoveGroupOption{}), group.MoveGroup)
m.Post("/new", reqToken(), reqGroupMembership(perm.AccessModeWrite, true), bind(api.NewGroupOption{}), group.NewSubGroup) m.Post("/new", reqToken(), reqGroupMembership(perm.AccessModeWrite, true), bind(api.NewGroupOption{}), group.NewSubGroup)
}) }, checkTokenPublicOnly())
}) })
return m return m
} }

View File

@ -104,7 +104,7 @@ func NewSubGroup(ctx *context.APIContext) {
// MoveGroup - move a group to a different group in the same organization, or to the root level if // MoveGroup - move a group to a different group in the same organization, or to the root level if
func MoveGroup(ctx *context.APIContext) { func MoveGroup(ctx *context.APIContext) {
// swagger:operation POST /orgs/{org}/groups/{group_id}/move repository-group groupMove // swagger:operation POST /groups/{group_id}/move repository-group groupMove
// --- // ---
// summary: move a group to a different parent group // summary: move a group to a different parent group
// consumes: // consumes:
@ -112,11 +112,6 @@ func MoveGroup(ctx *context.APIContext) {
// produces: // produces:
// - application/json // - application/json
// parameters: // parameters:
// - name: org
// in: path
// description: name of the organization
// type: string
// required: true
// - name: group_id // - name: group_id
// in: path // in: path
// description: id of the group to move // description: id of the group to move
@ -174,7 +169,7 @@ func MoveGroup(ctx *context.APIContext) {
// EditGroup - update a group in an organization // EditGroup - update a group in an organization
func EditGroup(ctx *context.APIContext) { func EditGroup(ctx *context.APIContext) {
// swagger:operation PATCH /orgs/{org}/groups/{group_id} repository-group groupEdit // swagger:operation PATCH /groups/{group_id} repository-group groupEdit
// --- // ---
// summary: edits a group in an organization. only fields that are set will be changed. // summary: edits a group in an organization. only fields that are set will be changed.
// consumes: // consumes:
@ -182,11 +177,6 @@ func EditGroup(ctx *context.APIContext) {
// produces: // produces:
// - application/json // - application/json
// parameters: // parameters:
// - name: org
// in: path
// description: name of the organization
// type: string
// required: true
// - name: group_id // - name: group_id
// in: path // in: path
// description: id of the group to edit // description: id of the group to edit
@ -243,17 +233,12 @@ func EditGroup(ctx *context.APIContext) {
} }
func GetGroup(ctx *context.APIContext) { func GetGroup(ctx *context.APIContext) {
// swagger:operation GET /orgs/{org}/groups/{group_id} repository-group groupGet // swagger:operation GET /groups/{group_id} repository-group groupGet
// --- // ---
// summary: gets a group in an organization // summary: gets a group in an organization
// produces: // produces:
// - application/json // - application/json
// parameters: // parameters:
// - name: org
// in: path
// description: name of the organization
// type: string
// required: true
// - name: group_id // - name: group_id
// in: path // in: path
// description: id of the group to retrieve // description: id of the group to retrieve
@ -297,7 +282,7 @@ func GetGroup(ctx *context.APIContext) {
} }
func DeleteGroup(ctx *context.APIContext) { func DeleteGroup(ctx *context.APIContext) {
// swagger:operation DELETE /orgs/{org}/groups/{group_id} repositoryGroup groupDelete // swagger:operation DELETE /groups/{group_id} repositoryGroup groupDelete
// --- // ---
// summary: Delete a repository group // summary: Delete a repository group
// produces: // produces: