Skip to content

Commit 3d1c79d

Browse files
committed
fix users being able bypass limits with repo transfers
1 parent c7b85f7 commit 3d1c79d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

routers/api/v1/repo/transfer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ func Transfer(ctx *context.APIContext) {
6868
return
6969
}
7070

71+
if !newOwner.CanCreateRepo() {
72+
ctx.APIError(http.StatusForbidden, "The new owner cannot have more repositories")
73+
}
74+
7175
if newOwner.Type == user_model.UserTypeOrganization {
7276
if !ctx.Doer.IsAdmin && newOwner.Visibility == api.VisibleTypePrivate && !organization.OrgFromUser(newOwner).HasMemberWithUserID(ctx, ctx.Doer.ID) {
7377
// The user shouldn't know about this organization

routers/web/repo/setting/setting.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,12 @@ func SettingsPost(ctx *context.Context) {
779779
return
780780
}
781781

782+
if !newOwner.CanCreateRepo() {
783+
limit := util.Iif(newOwner.MaxRepoCreation != -1, newOwner.MaxRepoCreation, setting.Repository.MaxCreationLimit)
784+
ctx.RenderWithErr(ctx.TrN(limit, "repo.form.reach_limit_of_creation_1", "repo.form.reach_limit_of_creation_n", limit), tplSettingsOptions, nil)
785+
return
786+
}
787+
782788
if newOwner.Type == user_model.UserTypeOrganization {
783789
if !ctx.Doer.IsAdmin && newOwner.Visibility == structs.VisibleTypePrivate && !organization.OrgFromUser(newOwner).HasMemberWithUserID(ctx, ctx.Doer.ID) {
784790
// The user shouldn't know about this organization

0 commit comments

Comments
 (0)