diff options
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/org/org.go | 4 | ||||
-rw-r--r-- | routers/api/v1/repo/repo.go | 5 | ||||
-rw-r--r-- | routers/home.go | 9 | ||||
-rw-r--r-- | routers/org/org.go | 9 | ||||
-rw-r--r-- | routers/org/setting.go | 4 | ||||
-rw-r--r-- | routers/repo/view.go | 5 | ||||
-rw-r--r-- | routers/user/home.go | 6 | ||||
-rw-r--r-- | routers/user/profile.go | 2 |
8 files changed, 41 insertions, 3 deletions
diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go index 59351e20d1..e3916046f0 100644 --- a/routers/api/v1/org/org.go +++ b/routers/api/v1/org/org.go @@ -129,6 +129,10 @@ func Get(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Organization" + if !models.HasOrgVisible(ctx.Org.Organization, ctx.User) { + ctx.NotFound("HasOrgVisible", nil) + return + } ctx.JSON(200, convert.ToOrganization(ctx.Org.Organization)) } diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index d78700c6b0..f69cbee0c0 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -302,6 +302,11 @@ func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) { return } + if !models.HasOrgVisible(org, ctx.User) { + ctx.NotFound("HasOrgVisible", nil) + return + } + if !ctx.User.IsAdmin { isOwner, err := org.IsOwnedBy(ctx.User.ID) if err != nil { diff --git a/routers/home.go b/routers/home.go index 7a23e8765e..a09d025d23 100644 --- a/routers/home.go +++ b/routers/home.go @@ -1,4 +1,5 @@ // Copyright 2014 The Gogs Authors. All rights reserved. +// Copyright 2019 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. @@ -230,6 +231,7 @@ func ExploreUsers(ctx *context.Context) { Type: models.UserTypeIndividual, PageSize: setting.UI.ExplorePagingNum, IsActive: util.OptionalBoolTrue, + Private: true, }, tplExploreUsers) } @@ -240,9 +242,16 @@ func ExploreOrganizations(ctx *context.Context) { ctx.Data["PageIsExploreOrganizations"] = true ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled + var ownerID int64 + if ctx.User != nil && !ctx.User.IsAdmin { + ownerID = ctx.User.ID + } + RenderUserSearch(ctx, &models.SearchUserOptions{ Type: models.UserTypeOrganization, PageSize: setting.UI.ExplorePagingNum, + Private: ctx.User != nil, + OwnerID: ownerID, }, tplExploreOrganizations) } diff --git a/routers/org/org.go b/routers/org/org.go index bb7540277c..3821b32216 100644 --- a/routers/org/org.go +++ b/routers/org/org.go @@ -1,4 +1,5 @@ // Copyright 2014 The Gogs Authors. All rights reserved. +// Copyright 2018 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. @@ -23,6 +24,7 @@ const ( // Create render the page for create organization func Create(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("new_org") + ctx.Data["DefaultOrgVisibilityMode"] = setting.Service.DefaultOrgVisibilityMode if !ctx.User.CanCreateOrganization() { ctx.ServerError("Not allowed", errors.New(ctx.Tr("org.form.create_org_not_allowed"))) return @@ -45,9 +47,10 @@ func CreatePost(ctx *context.Context, form auth.CreateOrgForm) { } org := &models.User{ - Name: form.OrgName, - IsActive: true, - Type: models.UserTypeOrganization, + Name: form.OrgName, + IsActive: true, + Type: models.UserTypeOrganization, + Visibility: form.Visibility, } if err := models.CreateOrganization(org, ctx.User); err != nil { diff --git a/routers/org/setting.go b/routers/org/setting.go index 7f652c11d6..1c4e75288a 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -1,4 +1,5 @@ // Copyright 2014 The Gogs Authors. All rights reserved. +// Copyright 2019 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. @@ -13,6 +14,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/structs" userSetting "code.gitea.io/gitea/routers/user/setting" ) @@ -29,6 +31,7 @@ const ( func Settings(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("org.settings") ctx.Data["PageIsSettingsOptions"] = true + ctx.Data["CurrentVisibility"] = structs.VisibleType(ctx.Org.Organization.Visibility) ctx.HTML(200, tplSettingsOptions) } @@ -79,6 +82,7 @@ func SettingsPost(ctx *context.Context, form auth.UpdateOrgSettingForm) { org.Description = form.Description org.Website = form.Website org.Location = form.Location + org.Visibility = form.Visibility if err := models.UpdateUser(org); err != nil { ctx.ServerError("UpdateUser", err) return diff --git a/routers/repo/view.go b/routers/repo/view.go index 02cf2cc0bd..da6c527242 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -303,6 +303,11 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st // Home render repository home page func Home(ctx *context.Context) { + if !models.HasOrgVisible(ctx.Repo.Repository.Owner, ctx.User) { + ctx.NotFound("HasOrgVisible", nil) + return + } + if len(ctx.Repo.Units) > 0 { var firstUnit *models.Unit for _, repoUnit := range ctx.Repo.Units { diff --git a/routers/user/home.go b/routers/user/home.go index 67a882af9c..c4e169befd 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -386,6 +386,12 @@ func showOrgProfile(ctx *context.Context) { } org := ctx.Org.Organization + + if !models.HasOrgVisible(org, ctx.User) { + ctx.NotFound("HasOrgVisible", nil) + return + } + ctx.Data["Title"] = org.DisplayName() var orderBy models.SearchOrderBy diff --git a/routers/user/profile.go b/routers/user/profile.go index afb74fe8c3..b1daa9e496 100644 --- a/routers/user/profile.go +++ b/routers/user/profile.go @@ -1,4 +1,5 @@ // Copyright 2015 The Gogs Authors. All rights reserved. +// Copyright 2019 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. @@ -98,6 +99,7 @@ func Profile(ctx *context.Context) { } ctx.Data["Orgs"] = orgs + ctx.Data["HasOrgsVisible"] = models.HasOrgsVisible(orgs, ctx.User) tab := ctx.Query("tab") ctx.Data["TabName"] = tab |