mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-04 08:17:24 -05:00
Allow forks to org if you can create repos (#17783)
This commit is contained in:
parent
4b4997c73e
commit
e0f81b4ef4
@ -766,7 +766,7 @@ func CanUserForkRepo(user *user_model.User, repo *Repository) (bool, error) {
|
|||||||
if repo.OwnerID != user.ID && !HasForkedRepo(user.ID, repo.ID) {
|
if repo.OwnerID != user.ID && !HasForkedRepo(user.ID, repo.ID) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
ownedOrgs, err := GetOwnedOrgsByUserID(user.ID)
|
ownedOrgs, err := GetOrgsCanCreateRepoByUserID(user.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -113,9 +113,9 @@ func getForkRepository(ctx *context.Context) *models.Repository {
|
|||||||
|
|
||||||
ctx.Data["ForkRepo"] = forkRepo
|
ctx.Data["ForkRepo"] = forkRepo
|
||||||
|
|
||||||
ownedOrgs, err := models.GetOwnedOrgsByUserID(ctx.User.ID)
|
ownedOrgs, err := models.GetOrgsCanCreateRepoByUserID(ctx.User.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("GetOwnedOrgsByUserID", err)
|
ctx.ServerError("GetOrgsCanCreateRepoByUserID", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var orgs []*models.Organization
|
var orgs []*models.Organization
|
||||||
@ -216,13 +216,13 @@ func ForkPost(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check ownership of organization.
|
// Check if user is allowed to create repo's on the organization.
|
||||||
if ctxUser.IsOrganization() {
|
if ctxUser.IsOrganization() {
|
||||||
isOwner, err := models.OrgFromUser(ctxUser).IsOwnedBy(ctx.User.ID)
|
isAllowedToFork, err := models.OrgFromUser(ctxUser).CanCreateOrgRepo(ctx.User.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("IsOwnedBy", err)
|
ctx.ServerError("CanCreateOrgRepo", err)
|
||||||
return
|
return
|
||||||
} else if !isOwner {
|
} else if !isAllowedToFork {
|
||||||
ctx.Error(http.StatusForbidden)
|
ctx.Error(http.StatusForbidden)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user