aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2014-10-25 07:50:19 -0400
committerUnknwon <joe2010xtmf@163.com>2014-10-25 07:50:19 -0400
commit83283bca4cb4e0f4ec48a28af680f0d88db3d2c8 (patch)
tree665b81c242a4d92811568367eb53dc3ba5eb1247 /routers
parentf1d87462642aa0ab4ce61e8a285e3a288b4dc119 (diff)
downloadgitea-83283bca4cb4e0f4ec48a28af680f0d88db3d2c8.tar.gz
gitea-83283bca4cb4e0f4ec48a28af680f0d88db3d2c8.zip
Safe work
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repos.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/routers/api/v1/repos.go b/routers/api/v1/repos.go
index 37a3e47a63..2dee512f2b 100644
--- a/routers/api/v1/repos.go
+++ b/routers/api/v1/repos.go
@@ -31,6 +31,26 @@ func SearchRepos(ctx *middleware.Context) {
opt.Limit = 10
}
+ // Check visibility.
+ if ctx.IsSigned && opt.Uid > 0 {
+ if ctx.User.Id == opt.Uid {
+ opt.Private = true
+ } else {
+ u, err := models.GetUserById(opt.Uid)
+ if err != nil {
+ ctx.JSON(500, map[string]interface{}{
+ "ok": false,
+ "error": err.Error(),
+ })
+ return
+ }
+ if u.IsOrganization() && u.IsOrgOwner(ctx.User.Id) {
+ opt.Private = true
+ }
+ // FIXME: how about collaborators?
+ }
+ }
+
repos, err := models.SearchRepositoryByName(opt)
if err != nil {
ctx.JSON(500, map[string]interface{}{