|
|
@@ -12,6 +12,7 @@ import ( |
|
|
|
"code.gitea.io/gitea/modules/context" |
|
|
|
"code.gitea.io/gitea/modules/convert" |
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
"code.gitea.io/gitea/modules/structs" |
|
|
|
api "code.gitea.io/gitea/modules/structs" |
|
|
|
repo_service "code.gitea.io/gitea/services/repository" |
|
|
|
) |
|
|
@@ -53,13 +54,21 @@ func Transfer(ctx *context.APIContext, opts api.TransferRepoOption) { |
|
|
|
newOwner, err := models.GetUserByName(opts.NewOwner) |
|
|
|
if err != nil { |
|
|
|
if models.IsErrUserNotExist(err) { |
|
|
|
ctx.Error(http.StatusNotFound, "GetUserByName", err) |
|
|
|
ctx.Error(http.StatusNotFound, "", "The new owner does not exist or cannot be found") |
|
|
|
return |
|
|
|
} |
|
|
|
ctx.InternalServerError(err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if newOwner.Type == models.UserTypeOrganization { |
|
|
|
if !ctx.User.IsAdmin && newOwner.Visibility == structs.VisibleTypePrivate && !newOwner.HasMemberWithUserID(ctx.User.ID) { |
|
|
|
// The user shouldn't know about this organization |
|
|
|
ctx.Error(http.StatusNotFound, "", "The new owner does not exist or cannot be found") |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var teams []*models.Team |
|
|
|
if opts.TeamIDs != nil { |
|
|
|
if !newOwner.IsOrganization() { |
|
|
|