0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-04-06 03:09:18 +02:00

add ownership check when moving repository to a new group

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2025-08-13 16:17:12 -04:00
parent 4ebc1e3da1
commit 47531417e9
No known key found for this signature in database
GPG Key ID: 924A5F6AF051E87C

View File

@ -44,6 +44,15 @@ func NewGroup(ctx context.Context, g *group_model.Group) (err error) {
func MoveRepositoryToGroup(ctx context.Context, repo *repo_model.Repository, newGroupID int64, groupSortOrder int) error {
sess := db.GetEngine(ctx)
if newGroupID > 0 {
newGroup, err := group_model.GetGroupByID(ctx, newGroupID)
if err != nil {
return err
}
if newGroup.OwnerID != repo.OwnerID {
return fmt.Errorf("repo[%d]'s ownerID is not equal to new parent group[%d]'s owner ID", repo.ID, newGroup.ID)
}
}
repo.GroupID = newGroupID
repo.GroupSortOrder = groupSortOrder
cnt, err := sess.