Skip to content

Commit d5377ca

Browse files
add ownership check when moving repository to a new group
1 parent 4500dcc commit d5377ca

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

services/group/group.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ func NewGroup(ctx context.Context, g *group_model.Group) (err error) {
4444

4545
func MoveRepositoryToGroup(ctx context.Context, repo *repo_model.Repository, newGroupID int64, groupSortOrder int) error {
4646
sess := db.GetEngine(ctx)
47+
if newGroupID > 0 {
48+
newGroup, err := group_model.GetGroupByID(ctx, newGroupID)
49+
if err != nil {
50+
return err
51+
}
52+
if newGroup.OwnerID != repo.OwnerID {
53+
return fmt.Errorf("repo[%d]'s ownerID is not equal to new parent group[%d]'s owner ID", repo.ID, newGroup.ID)
54+
}
55+
}
4756
repo.GroupID = newGroupID
4857
repo.GroupSortOrder = groupSortOrder
4958
cnt, err := sess.

0 commit comments

Comments
 (0)